def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master master_file = update_file(master, test_name) # Modify file in our repo contents = _read_file(master_file) contents = contents.replace('line 1', 'line x') repo_file = join(path, testfile_name) write_file(repo_file, contents) repo.index.add([repo_file]) repo.index.commit(test_name)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Crate test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) # repo = Repo.init(path) # update_file(repo, 'Initial commit') os.chdir(path) assert repo.working_dir == path # Rename test repo branch repo.git.branch(test_name + '_renamed', m=True) # Add subrepo write_file(join(path, '.gitmodules'), '') repo.create_submodule('sub', 'sub', master_path) repo.git.add('.gitmodules', 'sub/') repo.git.commit(m='Added submodule') repo.git.submodule('init') # Modify file in master update_file(master, test_name)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Set git-up.rebase.log-hook if platform.system() == 'Windows': repo.git.config( 'git-up.rebase.log-hook', 'IF [%1]==[] exit 1; ' # Note: this whole string is one line 'IF [%2]==[] exit 1; ' # and will be split by 'git up' to 'git log -n 1 $1 > nul; ' # multiple lines. 'git log -n 1 $2 > nul;' ) else: repo.git.config( 'git-up.rebase.log-hook', 'if [ -z "$1" -a -z "$2" ]; then exit 1; fi;' 'git log -n 1 "$1" &> /dev/null; ' 'git log -n 1 "$2" &> /dev/null;' ) # Modify file in master update_file(master, test_name)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master master_file = update_file(master, test_name) # Modify file in our repo contents = _read_file(master_file) contents = contents.replace('line 1', 'line x') repo_file = join(path, testfile_name) write_file(repo_file, contents) repo.index.add([repo_file]) repo.index.commit(test_name) # Set git-up.rebase.arguments to '--abort', what results in an # invalid cmd and thus git returning an error, that we look for. repo.git.config('git-up.rebase.arguments', '--abort')
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Create new local branch and set upstream repo.git.checkout(b=new_branch_name) repo.git.branch(u=origin_test_name) # Make non-conflicting change in new branch update_file(repo, new_branch_name, filename=another_file_name) # Modify file in master update_file(master, test_name) # Update first branch repo.git.checkout(test_name) repo.git.pull()
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master update_file(master, test_name) # Modify file in our repo contents = 'completely changed!' repo_file = join(path, testfile_name) write_file(repo_file, contents) repo.index.add([repo_file]) repo.index.commit(test_name) # Modify file in master update_file(master, test_name)
def setup(): master1_path, master1 = init_master(test_name + '.1') # Prepare master repo master1.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master1.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master update_file(master1, test_name) # Create second remote master2_path = join(basepath, 'master.' + test_name + '.2') master1.clone(master2_path, b=test_name) master2 = Repo(master2_path, odbt=GitCmdObjectDB) # Add second master as remote, too repo.git.checkout(b=test_name + '.2') repo.git.remote('add', 'upstream', master2_path) repo.git.fetch(all=True) repo.git.branch(set_upstream_to='upstream/' + test_name) update_file(master2, test_name)
def setup(): master_path, master = init_master(test_name) os.makedirs(git_dir) os.makedirs(work_tree) # Prepare master repo master.git.checkout(b=test_name) # Create work tree with open(join(work_tree, '.git'), 'w') as f: f.write('gitdir: ' + git_dir) # Clone master os.environ['GIT_DIR'] = git_dir os.environ['GIT_WORK_TREE'] = work_tree repo = Repo.init(work_tree) repo.git.remote('add', 'origin', master_path) repo.git.fetch('origin') repo.git.checkout('origin/' + test_name, b=test_name) del os.environ['GIT_DIR'] del os.environ['GIT_WORK_TREE'] # Modify file in our repo repo_path_file = join(master_path, testfile_name) write_file(repo_path_file, 'line 1\nline 2\ncounter: 2') master.index.add([repo_path_file]) master.index.commit(test_name)
def setup(): master_path, master = init_master(test_name) master_path2, master2 = init_master(test_name + '2') # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Configure git up repo.git.config('git-up.fetch.all', 'true') # Add second master repo to remotes repo.git.remote('add', test_name, master_path2)
def setup(): global repo_path master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Create branch with local tracking master.git.checkout(b=test_name + '_b', t=True) repo_path = master_path # Modify tracking branch master.git.checkout(test_name) update_file(master)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master update_file(master, test_name)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master update_file(master, test_name, filename='test1.txt') # Modify file in working directory write_file(join(path, 'test1.txt'), 'Hello world!')
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in our repo repo_path_file = join(path, testfile_name) write_file(repo_path_file, 'line 1\nline 2\ncounter: 2') repo.index.add([repo_path_file]) repo.index.commit(test_name)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Set remote repo.git.remote('set-url', 'origin', 'does-not-exist') # Modify file in master update_file(master, test_name)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Add Gemfile gemfile = join(master_path, 'Gemfile') write_file(gemfile, "source 'https://rubygems.org'\ngem 'colored'") master.index.add([gemfile]) master.index.commit(test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) repo.git.config('git-up.bundler.check', 'true') assert repo.working_dir == path
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Set git-up.rebase.auto to false repo.git.config('git-up.rebase.auto', 'false') # Modify file in master update_file(master, test_name) # Modify file in our repo update_file(repo, test_name)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) testfile_path = join(path, testfile_name) assert repo.working_dir == path # Modify file in master master_path_file = join(master_path, testfile_name) write_file(master_path_file, 'contents1') master.index.add([master_path_file]) master.index.commit(test_name) # Create unmerged paths in working dir branch_master = repo.active_branch branch_changed = repo.create_head(test_name + '.branch') branch_changed.set_commit('HEAD') branch_changed.checkout() write_file(testfile_path, 'contents1') repo.index.add([testfile_path]) repo.index.commit('Update in branch') branch_master.checkout() write_file(testfile_path, 'contents2') repo.index.add([testfile_path]) repo.index.commit('Update in origin') try: repo.git.merge(test_name + '.branch') except GitCommandError: pass
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Create new branch master.git.checkout(b=new_branch_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Checkout new branch in cloned repo repo.git.checkout(new_branch_name, 'origin/' + new_branch_name, b=True) # Remove branch from master again master.git.checkout(test_name) master.git.branch(new_branch_name, d=True)
def setup(): master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master master_path_file = join(master_path, testfile_name) write_file(master_path_file, 'contents') master.index.add([master_path_file]) master.index.commit(test_name) # Modify file in repo path_file = join(path, testfile_name) os.unlink(path_file)
def setup(): if Git().version_info[:3] < (2, 5, 1): return master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) # Create work tree clone = Repo(path, odbt=GitCmdObjectDB) clone.git.worktree("add", "../" + worktree_dir) # repo = Repo(worktree_path, odbt=GitCmdObjectDB) # assert repo.working_dir == worktree_path # Modify file in master update_file(master, test_name)
def setup(): if Git().version_info[:3] < (2, 5, 1): return master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) # Create work tree clone = Repo(path, odbt=GitCmdObjectDB) clone.git.worktree('add', '../' + worktree_dir) # repo = Repo(worktree_path, odbt=GitCmdObjectDB) # assert repo.working_dir == worktree_path # Modify file in master update_file(master, test_name)
def setup(): master_path, master = init_master(test_name) master.git.config('receive.denyCurrentBranch', 'ignore', add=True) # Prepare master repo master.git.checkout(b=test_name) # Clone to test repo path = join(basepath, test_name) master.clone(path, b=test_name) repo = Repo(path, odbt=GitCmdObjectDB) assert repo.working_dir == path # Modify file in master update_file(master, test_name) # Modify file in our repo repo_file = join(path, 'file2.txt') write_file(repo_file, 'test') repo.index.add([repo_file]) repo.index.commit(test_name)
def setup(): global master_path master_path, master = init_master(test_name) # Prepare master repo master.git.checkout(b=test_name)