Exemple #1
0
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)
Exemple #2
0
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')
Exemple #3
0
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)
Exemple #4
0
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)
Exemple #5
0
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)
Exemple #6
0
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 test_submodules_dirty():
    """ Run 'git up' with submodules in a dirty repo """
    repo = Repo(repo_path)
    repo_head = repo.head.commit.hexsha
    submod_head = repo.submodules[0].hexsha

    # Change file in submodule
    write_file('sub/file', 'submodule changed')

    from PyGitUp.gitup import GitUp
    gitup = GitUp(testing=True)

    # PyGitUp uses the main repo
    assert_equal(repo_head, gitup.git.repo.head.commit.hexsha)

    gitup.run()

    assert_equal(len(gitup.states), 1)
    assert_equal(gitup.states[0], 'rebasing')
Exemple #8
0
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

    # 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 test_submodules_dirty():
    """ Run 'git up' with submodules in a dirty repo """
    repo = Repo(repo_path)
    repo_head = repo.head.commit.hexsha
    submod_head = repo.submodules[0].hexsha

    # Change file in submodule
    write_file('sub/file', 'submodule changed')

    from PyGitUp.gitup import GitUp
    gitup = GitUp(testing=True)

    # PyGitUp uses the main repo
    assert_equal(repo_head, gitup.git.repo.head.commit.hexsha)

    gitup.run()

    assert_equal(len(gitup.states), 1)
    assert_equal(gitup.states[0], 'rebasing')
Exemple #12
0
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
Exemple #13
0
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
Exemple #14
0
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)
Exemple #15
0
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)
Exemple #16
0
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)
Exemple #17
0
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