本文整理匯總了Python中datalad.support.gitrepo.GitRepo.git_add方法的典型用法代碼示例。如果您正苦於以下問題:Python GitRepo.git_add方法的具體用法?Python GitRepo.git_add怎麽用?Python GitRepo.git_add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datalad.support.gitrepo.GitRepo
的用法示例。
在下文中一共展示了GitRepo.git_add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_GitRepo_add
# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import git_add [as 別名]
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))
示例2: test_GitRepo_commit
# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import git_add [as 別名]
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=[])
示例3: test_install_plain_git
# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import git_add [as 別名]
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())