本文整理汇总了Python中datalad.support.gitrepo.GitRepo.git_remote_add方法的典型用法代码示例。如果您正苦于以下问题:Python GitRepo.git_remote_add方法的具体用法?Python GitRepo.git_remote_add怎么用?Python GitRepo.git_remote_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datalad.support.gitrepo.GitRepo
的用法示例。
在下文中一共展示了GitRepo.git_remote_add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_publish_recursive
# 需要导入模块: from datalad.support.gitrepo import GitRepo [as 别名]
# 或者: from datalad.support.gitrepo.GitRepo import git_remote_add [as 别名]
def test_publish_recursive(origin, src_path, dst_path, sub1_pub, sub2_pub):
# prepare src
source = install(path=src_path, source=origin, recursive=True)
# TODO: For now, circumnavigate the detached head issue.
# Figure out, what to do.
for subds in source.get_dataset_handles(recursive=True):
AnnexRepo(opj(src_path, subds), init=True, create=True).git_checkout("master")
# create plain git at target:
target = GitRepo(dst_path, create=True)
target.git_checkout("TMP", "-b")
source.repo.git_remote_add("target", dst_path)
# subdatasets have no remote yet, so recursive publishing should fail:
with assert_raises(ValueError) as cm:
publish(dataset=source, dest="target", recursive=True)
assert_in("No sibling 'target' found.", str(cm.exception))
# now, set up targets for the submodules:
sub1_target = GitRepo(sub1_pub, create=True)
sub1_target.git_checkout("TMP", "-b")
sub2_target = GitRepo(sub2_pub, create=True)
sub2_target.git_checkout("TMP", "-b")
sub1 = GitRepo(opj(src_path, 'sub1'), create=False)
sub2 = GitRepo(opj(src_path, 'sub2'), create=False)
sub1.git_remote_add("target", sub1_pub)
sub2.git_remote_add("target", sub2_pub)
# publish recursively
res = publish(dataset=source, dest="target", recursive=True)
# testing result list
# (Note: Dataset lacks __eq__ for now. Should this be based on path only?)
assert_is_instance(res, list)
for item in res:
assert_is_instance(item, Dataset)
eq_(res[0].path, src_path)
eq_(res[1].path, sub1.path)
eq_(res[2].path, sub2.path)
eq_(list(target.git_get_branch_commits("master")),
list(source.repo.git_get_branch_commits("master")))
eq_(list(target.git_get_branch_commits("git-annex")),
list(source.repo.git_get_branch_commits("git-annex")))
eq_(list(sub1_target.git_get_branch_commits("master")),
list(sub1.git_get_branch_commits("master")))
eq_(list(sub1_target.git_get_branch_commits("git-annex")),
list(sub1.git_get_branch_commits("git-annex")))
eq_(list(sub2_target.git_get_branch_commits("master")),
list(sub2.git_get_branch_commits("master")))
eq_(list(sub2_target.git_get_branch_commits("git-annex")),
list(sub2.git_get_branch_commits("git-annex")))