def test_get_missing(path): repo = GitRepo(path, create=True) os.makedirs(op.join(path, 'deep')) with open(op.join(path, 'test1'), 'w') as f: f.write('some') with open(op.join(path, 'deep', 'test2'), 'w') as f: f.write('some more') # no files tracked yet, so nothing changed eq_(repo.get_changed_files(), []) repo.add('.') # still no differences between worktree and staged eq_(repo.get_changed_files(), []) eq_(set(repo.get_changed_files(staged=True)), {'test1', op.join('deep', 'test2')}) eq_(set(repo.get_changed_files(staged=True, diff_filter='AD')), {'test1', op.join('deep', 'test2')}) eq_(repo.get_changed_files(staged=True, diff_filter='D'), []) repo.commit() eq_(repo.get_changed_files(), []) eq_(repo.get_changed_files(staged=True), []) ok_clean_git(path, annex=False) unlink(op.join(path, 'test1')) eq_(repo.get_missing_files(), ['test1']) rmtree(op.join(path, 'deep')) eq_(sorted(repo.get_missing_files()), [op.join('deep', 'test2'), 'test1']) # nothing is actually known to be deleted eq_(repo.get_deleted_files(), []) # do proper removal repo.remove(op.join(path, 'test1')) # no longer missing eq_(repo.get_missing_files(), [op.join('deep', 'test2')]) # but deleted eq_(repo.get_deleted_files(), ['test1'])
def test_get_missing(path): repo = GitRepo(path, create=True) os.makedirs(op.join(path, 'deep')) with open(op.join(path, 'test1'), 'w') as f: f.write('some') with open(op.join(path, 'deep', 'test2'), 'w') as f: f.write('some more') # no files tracked yet, so nothing changed eq_(repo.get_changed_files(), []) repo.add('.') # still no differences between worktree and staged eq_(repo.get_changed_files(), []) eq_(set(repo.get_changed_files(staged=True)), {'test1', op.join('deep', 'test2')}) eq_(set(repo.get_changed_files(staged=True, diff_filter='AD')), {'test1', op.join('deep', 'test2')}) eq_(repo.get_changed_files(staged=True, diff_filter='D'), []) repo.commit() eq_(repo.get_changed_files(), []) eq_(repo.get_changed_files(staged=True), []) ok_clean_git(path, annex=False) unlink(op.join(path, 'test1')) eq_(repo.get_missing_files(), ['test1']) rmtree(op.join(path, 'deep')) eq_(sorted(repo.get_missing_files()), [op.join('deep', 'test2'), 'test1']) # nothing is actually known to be deleted eq_(repo.get_deleted_files(), []) # do proper removal repo.remove(op.join(path, 'test1')) # no longer missing eq_(repo.get_missing_files(), [op.join('deep', 'test2')]) # but deleted eq_(repo.get_deleted_files(), ['test1'])
def test_GitRepo_remove(path): gr = GitRepo(path, create=True) gr.add('*') gr.commit("committing all the files") eq_(gr.remove('file'), ['file']) eq_(set(gr.remove('d', r=True, f=True)), {'d/f1', 'd/f2'}) eq_(set(gr.remove('*', r=True, f=True)), {'file2', 'd2/f1', 'd2/f2'})
def test_GitRepo_remove(path): gr = GitRepo(path, create=True) gr.add('*') gr.commit("committing all the files") eq_(gr.remove('file'), ['file']) eq_(set(gr.remove('d', r=True, f=True)), {'d/f1', 'd/f2'}) eq_(set(gr.remove('*', r=True, f=True)), {'file2', 'd2/f1', 'd2/f2'})
def test_get_missing(path): repo = GitRepo(path, create=True) os.makedirs(op.join(path, 'deep')) with open(op.join(path, 'test1'), 'w') as f: f.write('some') with open(op.join(path, 'deep', 'test2'), 'w') as f: f.write('some more') repo.add('.') repo.commit() ok_clean_git(path, annex=False) os.unlink(op.join(path, 'test1')) eq_(repo.get_missing_files(), ['test1']) rmtree(op.join(path, 'deep')) eq_(sorted(repo.get_missing_files()), [op.join('deep', 'test2'), 'test1']) # nothing is actually known to be deleted eq_(repo.get_deleted_files(), []) # do proper removal repo.remove(op.join(path, 'test1')) # no longer missing eq_(repo.get_missing_files(), [op.join('deep', 'test2')]) # but deleted eq_(repo.get_deleted_files(), ['test1'])