本文整理汇总了Python中datalad.support.gitrepo.GitRepo.add_submodule方法的典型用法代码示例。如果您正苦于以下问题:Python GitRepo.add_submodule方法的具体用法?Python GitRepo.add_submodule怎么用?Python GitRepo.add_submodule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datalad.support.gitrepo.GitRepo
的用法示例。
在下文中一共展示了GitRepo.add_submodule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_GitRepo_gitignore
# 需要导入模块: from datalad.support.gitrepo import GitRepo [as 别名]
# 或者: from datalad.support.gitrepo.GitRepo import add_submodule [as 别名]
def test_GitRepo_gitignore(path):
gr = GitRepo(path, create=True)
sub = GitRepo(op.join(path, 'ignore-sub.me'))
# we need to commit something, otherwise add_submodule
# will already refuse the submodule for having no commit
sub.add('a_file.txt')
sub.commit()
from ..exceptions import GitIgnoreError
with open(op.join(path, '.gitignore'), "w") as f:
f.write("*.me")
with assert_raises(GitIgnoreError) as cme:
gr.add('ignore.me')
eq_(cme.exception.paths, ['ignore.me'])
with assert_raises(GitIgnoreError) as cme:
gr.add_submodule(path='ignore-sub.me')
eq_(cme.exception.paths, ['ignore-sub.me'])
with assert_raises(GitIgnoreError) as cme:
gr.add(['ignore.me', 'dontigno.re', op.join('ignore-sub.me', 'a_file.txt')])
eq_(set(cme.exception.paths), {'ignore.me', 'ignore-sub.me'})
eq_(gr.get_gitattributes('.')['.'], {}) # nothing is recorded within .gitattributes
示例2: test_GitRepo_add_submodule
# 需要导入模块: from datalad.support.gitrepo import GitRepo [as 别名]
# 或者: from datalad.support.gitrepo.GitRepo import add_submodule [as 别名]
def test_GitRepo_add_submodule(source, path):
top_repo = GitRepo(path, create=True)
top_repo.add_submodule('sub', name='sub', url=source)
top_repo.commit('submodule added')
eq_([s.name for s in top_repo.get_submodules()], ['sub'])
ok_clean_git(path)
ok_clean_git(op.join(path, 'sub'))