def test_contribute_on_wrong_branch_by_commit(self, git, engine): hotfix_mock = mock.MagicMock() hotfix_mock.name.startswith.return_value = True git().branches = [hotfix_mock] # ensure that the "commit" isn't in the iter_parents hotfix_mock.commit = False git().head.reference.object.iter_parents.return_value = [True] assert not engine.contribute_hotfix()
def git_sync_temp(proj_id, dest_path): ''' change path to project repository configure dest_path as other remote repository execute pull from the other remote repository change back to the original path ref: http://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another ''' # change directory to project repository original_path = repo_path.cd_proj_repo(proj_id) dest_path_list = os.listdir(dest_path) other_repo_path = os.path.join(dest_path, dest_path_list[0]) # configure other remote repository remote_string = "remote add other %s" % (other_repo_path) print(("download_n_sync() :", remote_string)) git(remote_string) # execute pull git("fetch other") git("checkout master") git("merge other/master") # change back to original path os.chdir(original_path)
def test_contribute(self, git, engine, release_manager): hotfix_mock = mock.MagicMock() hotfix_mock.name.startswith.return_value = True hotfix_mock.commit = True git().branches = [hotfix_mock] git().head.reference.object.iter_parents.return_value = [True] assert engine.contribute_hotfix() release_manager.assert_has_calls([ mock.call().contribute(git().head.reference, mock.ANY), ])
def test_publish_on_hotfix_branch(self, engine, git, id_generator, repository_structure): return_branch = engine.develop git().head.reference.name = repository_structure['hotfix'] + id_generator() assert engine.publish_hotfix() return_branch.assert_has_calls([ mock.call.checkout(), ])
def test_start_with_existing_release(self, id_generator, git, engine, release_manager): name = id_generator() release_mock = mock.MagicMock() release_mock.name.startswith.return_value = True git().branches = [release_mock] assert not engine.start_release(name) assert release_manager.return_value.call_count == 0
def test_start_with_existing_hotfix(self, id_generator, git, engine, hotfix_manager): name = id_generator() hotfix_mock = mock.MagicMock() hotfix_mock.name.startswith.return_value = True git().branches = [hotfix_mock] assert not engine.start_hotfix(name) assert hotfix_manager.return_value.call_count == 0
def git_ci(): git_up() initial_branch = current_branch() commit_description = prompt_multiple_lines("Enter a commit description. The frist line will be the summary.") commit_description_by_line = commit_description.split("\n") summary = commit_description_by_line[0] # git("checkout", "master") # git("merge --squash", initial_branch) git_subtree_push("scripts", "scripts") git_subtree_push("primary", "app/assets/stylesheets/primary") # Git up will merge in master and any subtree changes # We then want to push your branch to origin HEAD # Open a pull request with your summary and close any issues. # Dump you back on master with all the updated changes. git("push -u origin HEAD") pull_request(commit_description) git("checkout master")
def test_abandon(self, id_generator, engine, feature_manager, git): name = id_generator() return_branch = mock.MagicMock() git().head.reference = return_branch assert engine.abandon_feature(name) return_branch.assert_has_calls([ mock.call.checkout(), ]) feature_manager.assert_has_calls([ mock.call().abandon(name, summary=mock.ANY), ])
def test_abandon_while_on_branch(self, id_generator, engine, feature_manager, git, repository_structure): name = id_generator() git().head.reference.name = repository_structure['feature'] + name return_branch = engine.develop assert engine.abandon_feature() return_branch.assert_has_calls([ mock.call.checkout(), ]) feature_manager.assert_has_calls([ mock.call().abandon(name, summary=mock.ANY), ])
def test_publish_not_on_hotfix_branch(self, id_generator, git, engine, hotfix_manager): name = id_generator() return_branch = mock.MagicMock() git().head.reference = return_branch assert engine.publish_hotfix(name) hotfix_manager.assert_has_calls([ mock.call().publish(name, None, True, mock.ANY), ]) return_branch.assert_has_calls([ mock.call.checkout(), ])
def test_accept(self, id_generator, engine, feature_manager, git): name = id_generator() return_branch = mock.MagicMock() git().head.reference = return_branch assert engine.accept_feature(name) feature_manager.assert_has_calls([ mock.call().accept( name, summary=mock.ANY, with_delete=True, ), ]) return_branch.assert_has_calls([ mock.call.checkout(), ])
def status(): git("status")
def push(remote=None, branch=None): remote, branch = get_remote_and_branch(remote, branch) git(("push", remote, branch))
def pull(remote=None, branch=None): remote, branch = get_remote_and_branch(remote, branch) git(("pull", remote, branch))
def checkout(branch): git(("checkout", branch))
def commit(message): git("""commit -a -m "%s" """ % message.replace('"', '\"'))
allurls=repofiledata.readlines() filecount=len(allurls) failedfilecount=0 processedfilecunt=0 print("Total Files to process "+ str(filecount)) logfile.write("Total Files to process "+ str(filecount)+"\n") for repo in allurls: repourl=repo.strip() repofolder=repo.split('/')[-1].strip() print(repofolder) print("Processing "+ repourl) try: print git('clone',repourl,folder_to_clonein+repofolder) logfile.write("Successfully processed " + repourl) processedfilecunt+=1 except: print(" Failed to Clone " + repourl) logfile.write("Processein failed for " + repourl+"\n") failedfilecount+=1 print("Files Suceessfuly procesed "+ str(processedfilecunt)) logfile.write("Files Suceessfuly procesed "+ str(filecount-failedfilecount)+"\n") print("Files Failed "+ str(failedfilecount)) logfile.write("Files Failed "+ str(failedfilecount)+"\n") logfile.close()
def test_contribute_on_wrong_branch_by_existance(self, git, engine): git().branches = [] assert not engine.contribute_hotfix()