コード例 #1
0
def test_copy_after_commit(env):
    '''Copying a file after a commit should create another link'''
    source = join(env.repo_dir, 'foo')
    open(source, 'w').write(HELLO_CONTENT)

    dest = join(env.repo_dir, 'bar')

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    # add the file to git-big
    check_output(['git', 'big', 'add', source])

    # make a commit
    check_output(['git', 'commit', '-m', 'commit'])

    # copy the link
    check_output(['git', 'big', 'cp', source, dest])

    # git should track the source and dest
    check_call(['git', 'status'])
    check_status(['M  .gitbig', 'A  bar'])

    # we should have two links to the same object
    check_locked_file(env, source, HELLO_DIGEST)
    check_locked_file(env, dest, HELLO_DIGEST)
コード例 #2
0
ファイル: test_mv.py プロジェクト: flaub/git-big
def test_move_after_commit(env):
    '''Moving a file after a commit should move the link'''
    source = join(env.repo_dir, 'foo')
    open(source, 'w').write(HELLO_CONTENT)

    dest = join(env.repo_dir, 'bar')

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    # add the file to git-big
    check_output(['git', 'big', 'add', source])

    # make a commit
    check_output(['git', 'commit', '-m', 'commit'])

    # move the link
    check_output(['git', 'big', 'mv', source, dest])

    # git should track the dest
    check_call(['git', 'status'])
    check_status(['M  .gitbig', 'R  foo -> bar'])

    # the file should now be moved
    assert not exists(source)
    check_locked_file(env, dest, HELLO_DIGEST)
コード例 #3
0
def test_add(env):
    '''Adding a file to a worktree'''

    # create an initial commit
    touched = join(env.repo_dir, 'xxx')
    open(touched, 'w').close()
    check_output(['git', 'add', touched])
    check_output(['git', 'commit', '-m', 'commit'])

    # create a worktree
    check_output(['git', 'worktree', 'add', 'worktree'])

    # change directory into the worktree
    os.chdir('worktree')

    open('foo', 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['?? foo'])

    # add the file
    check_output(['git', 'big', 'add', 'foo'])

    # status should show two pending changes
    check_status(['A  .gitbig', 'A  foo'])

    # verify link is working
    check_locked_file(env, 'foo', HELLO_DIGEST, '.')
コード例 #4
0
ファイル: test_add.py プロジェクト: brianretford/git-big
def add_file(env, file_, digest, expected_status):
    # add the file to git-big
    check_output(['git', 'big', 'add', file_])

    # git should now ignore the new file
    check_status(expected_status)

    check_locked_file(env, file_, digest)
コード例 #5
0
ファイル: test_add.py プロジェクト: brianretford/git-big
def test_add(env):
    '''Adding a file should link to a single cache object'''
    file_ = join(env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    add_file(env, file_, HELLO_DIGEST,
             ['A  .gitattributes', 'A  .gitbig', 'A  foo'])
コード例 #6
0
ファイル: test_add.py プロジェクト: brianretford/git-big
def test_add_same_multi(env):
    '''Adding a file a second time should be a nop'''
    file_ = join(env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    add_file(env, file_, HELLO_DIGEST,
             ['A  .gitattributes', 'A  .gitbig', 'A  foo'])
    add_file(env, file_, HELLO_DIGEST,
             ['A  .gitattributes', 'A  .gitbig', 'A  foo'])
コード例 #7
0
ファイル: test_add.py プロジェクト: brianretford/git-big
def test_add_same_content(env):
    '''Adding a file with the same content twice should link to a single cache object'''
    file1 = join(env.repo_dir, 'foo')
    open(file1, 'w').write(HELLO_CONTENT)
    file2 = join(env.repo_dir, 'bar')
    open(file2, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? bar', '?? foo'])

    add_file(env, file1, HELLO_DIGEST,
             ['A  .gitattributes', 'A  .gitbig', 'A  foo', '?? bar'])
    add_file(env, file2, HELLO_DIGEST,
             ['A  .gitattributes', 'A  .gitbig', 'A  bar', 'A  foo'])
コード例 #8
0
ファイル: test_add.py プロジェクト: brianretford/git-big
def test_add_changed(env):
    '''Adding a file and then changing its content should result in a new link'''
    file_ = join(env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    add_file(env, file_, HELLO_DIGEST,
             ['A  .gitattributes', 'A  .gitbig', 'A  foo'])

    os.unlink(file_)
    open(file_, 'w').write(WORLD_CONTENT)

    add_file(env, file_, WORLD_DIGEST,
             ['A  .gitattributes', 'A  .gitbig', 'A  foo'])
コード例 #9
0
def test_remove(env):
    '''Removing a file should remove the link and index entry'''
    file_ = join(env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    # add the file to git-big
    check_output(['git', 'big', 'add', file_])

    # remove the file
    check_output(['git', 'big', 'rm', file_])

    # git should not report that there is an untracked file
    check_status(['A  .gitattributes'])

    # file should be gone
    assert not exists(file_)
コード例 #10
0
def test_unlock_one_of_two(env):
    '''Unlocking a single file out of multiple pending changes'''
    file1 = join(env.repo_dir, 'foo')
    open(file1, 'w').write(HELLO_CONTENT)
    file2 = join(env.repo_dir, 'bar')
    open(file2, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? bar', '?? foo'])

    # add the files to git-big
    check_output(['git', 'big', 'add', file1])
    check_output(['git', 'big', 'add', file2])

    # git should now track the new files
    check_status(['A  .gitattributes', 'A  .gitbig', 'A  bar', 'A  foo'])

    # unlock the file
    check_output(['git', 'big', 'unlock', file1])

    # git should report that file1 is untracked but file2 is still tracked
    check_call(['git', 'status'])
    check_status(['A  .gitattributes', 'A  .gitbig', 'A  bar', '?? foo'])

    # we should have a normal file and a linked file
    assert not fs.islink(file1)
    assert fs.isfile(file1)
    assert fs.islink(file2)

    # unlocked files should be writable
    open(file1, 'w').write('ok')

    # locked files should remain read-only
    check_locked_file(env, file2, HELLO_DIGEST)
コード例 #11
0
def test_unlock(env):
    '''Unlocking a file should replace the symlink with a copy of the file'''
    file_ = join(env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    # add the file to git-big
    check_output(['git', 'big', 'add', file_])

    # git should now track the new file
    check_status(['A  .gitattributes', 'A  .gitbig', 'A  foo'])

    # unlock the file
    check_output(['git', 'big', 'unlock', file_])

    # git should report that the file is untracked
    check_call(['git', 'status'])
    check_status(['A  .gitattributes', '?? foo'])

    # we should have a normal file
    assert not fs.islink(file_)
    assert fs.isfile(file_)

    # unlocked files should be writable
    open(file_, 'w').write('ok')
コード例 #12
0
def test_checkout(env):
    '''Switch between branches, hooks should pull and update links'''
    # add a file
    file_ = join(env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)
    check_output(['git', 'big', 'add', file_])

    # commit the changes
    check_call(['git', 'status'])
    check_output(['git', 'commit', '-m', '1st commit'])
    check_status([])

    # make a new branch
    check_output(['git', 'checkout', '-b', 'changed'])

    # change a file
    check_output(['git', 'big', 'unlock', file_])
    open(file_, 'w').write(WORLD_CONTENT)
    check_output(['git', 'big', 'add', file_])

    # commit the changes
    check_call(['git', 'status'])
    check_output(['git', 'commit', '-m', '2nd commit'])
    check_status([])

    # switch back to 1st branch
    check_output(['git', 'checkout', 'master'])
    check_locked_file(env, file_, HELLO_DIGEST)
    check_anchors(env, [HELLO_DIGEST])

    # switch back to master branch
    check_output(['git', 'checkout', 'changed'])
    check_locked_file(env, file_, WORLD_DIGEST)
    check_anchors(env, [WORLD_DIGEST])

    # switch back to 1st branch
    check_output(['git', 'checkout', 'master'])
    check_locked_file(env, file_, HELLO_DIGEST)
    check_anchors(env, [HELLO_DIGEST])
コード例 #13
0
def test_remove_after_commit(env):
    '''Removing a file after a commit should remove the link and index entry'''
    file_ = join(env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? foo'])

    # add the file to git-big
    check_output(['git', 'big', 'add', file_])

    # make a commit
    check_output(['git', 'commit', '-m', 'commit'])

    # remove the file
    check_output(['git', 'big', 'rm', file_])

    # git should show deletions
    check_status(['D  .gitbig', 'D  foo'])

    # file should be gone
    assert not exists(file_)
コード例 #14
0
ファイル: test_add.py プロジェクト: brianretford/git-big
def test_add_directory(env):
    '''Adding a directory should recursively add all files underneath'''
    dir1 = join(env.repo_dir, 'dir')
    file1 = join(dir1, 'foo')
    dir2 = join(dir1, 'dir')
    file2 = join(dir2, 'foo')
    os.makedirs(dir2)

    open(file1, 'w').write(HELLO_CONTENT)
    open(file2, 'w').write(WORLD_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? dir/'])

    # add the directory to git-big
    check_output(['git', 'big', 'add', 'dir'])

    # git should now ignore the new files
    check_status(
        ['A  .gitattributes', 'A  .gitbig', 'A  dir/dir/foo', 'A  dir/foo'])

    check_locked_file(env, file1, HELLO_DIGEST)
    check_locked_file(env, file2, WORLD_DIGEST)
コード例 #15
0
ファイル: test_pull.py プロジェクト: flaub/git-big
def test_checkout_diff_types(depot_env):
    '''Switch between branches, hooks should pull and update links.
    1st commit is a big file, 2nd commit is a normal file.'''
    # add a file
    file_ = join(depot_env.repo_dir, 'foo')
    open(file_, 'w').write(HELLO_CONTENT)
    check_output(['git', 'big', 'add', file_])

    # commit the changes
    check_call(['git', 'status'])
    check_output(['git', 'commit', '-m', '1st commit'])
    check_status([])

    # make a new branch
    check_output(['git', 'checkout', '-b', 'changed'])

    # change a file
    check_output(['git', 'big', 'unlock', file_])
    open(file_, 'w').write(WORLD_CONTENT)
    check_output(['git', 'add', file_])

    # commit the changes
    check_call(['git', 'status'])
    check_output(['git', 'commit', '-m', '2nd commit'])
    check_status([])

    # switch back to 1st branch
    check_output(['git', 'checkout', 'master'])
    check_locked_file(depot_env, file_, HELLO_DIGEST)

    # switch back to master branch
    check_output(['git', 'checkout', 'changed'])
    assert not fs.islink(file_)

    # switch back to 1st branch
    check_output(['git', 'checkout', 'master'])
    check_locked_file(depot_env, file_, HELLO_DIGEST)
コード例 #16
0
def test_unlock_after_commit(env):
    '''Unlocking a file after a commit'''
    file1 = join(env.repo_dir, 'foo')
    open(file1, 'w').write(HELLO_CONTENT)
    file2 = join(env.repo_dir, 'bar')
    open(file2, 'w').write(HELLO_CONTENT)

    # git should report that the repo is dirty
    check_status(['A  .gitattributes', '?? bar', '?? foo'])

    # add the files to git-big
    check_output(['git', 'big', 'add', file1])
    check_output(['git', 'big', 'add', file2])

    # make a commit
    check_output(['git', 'commit', '-m', 'commit'])

    # unlock the file
    check_output(['git', 'big', 'unlock', file1])

    # git should report that file1 is deleted and untracked but file2 is still tracked
    check_call(['git', 'status'])
    check_status(['M  .gitbig', 'D  foo', '?? foo'])

    # we should have a normal file and a linked file
    assert not fs.islink(file1)
    assert fs.isfile(file1)
    assert fs.islink(file2)

    # unlocked files should be writable
    open(file1, 'w').write('ok')

    # locked files should remain read-only
    check_locked_file(env, file2, HELLO_DIGEST)

    # save the change
    check_output(['git', 'big', 'add', file1])

    # see that the file is now modified
    check_call(['git', 'status'])
    check_status(['M  .gitbig', 'M  foo'])