本文整理匯總了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")))