def test_install_plain_git(src, path): # make plain git repo gr = GitRepo(src, create=True) gr.git_add('test.txt') gr.git_commit('demo') # now install it somewhere else ds = install(path=path, source=src) # stays plain Git repo ok_(isinstance(ds.repo, GitRepo)) # now go back to original ds = Dataset(src) ok_(isinstance(ds.repo, GitRepo)) # installing a file must fail, as we decided not to perform magical upgrades # GitRepo -> AnnexRepo assert_raises(RuntimeError, ds.install, path='test2.txt', source=opj(src, 'test2.txt')) # but works when forced ifiles = ds.install(path='test2.txt', source=opj(src, 'test2.txt'), add_data_to_git=True) ok_startswith(ifiles, ds.path) ok_(ifiles.endswith('test2.txt')) ok_('test2.txt' in ds.repo.get_indexed_files())
def test_GitRepo_add(src, path): gr = GitRepo(path, src) filename = "test_git_add.dat" with open(os.path.join(path, filename), 'w') as f: f.write("File to add to git") gr.git_add(filename) assert_in(filename, gr.get_indexed_files(), "%s not successfully added to %s" % (filename, path))
def test_GitRepo_commit(path): gr = GitRepo(path) filename = "test_git_add.dat" with open(os.path.join(path, filename), 'w') as f: f.write("File to add to git") gr.git_add(filename) gr.git_commit("Testing GitRepo.git_commit().") ok_clean_git(path, annex=False, untracked=[])