本文整理匯總了Python中datalad.support.gitrepo.GitRepo.push方法的典型用法代碼示例。如果您正苦於以下問題:Python GitRepo.push方法的具體用法?Python GitRepo.push怎麽用?Python GitRepo.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datalad.support.gitrepo.GitRepo
的用法示例。
在下文中一共展示了GitRepo.push方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_GitRepo_ssh_push
# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import push [as 別名]
def test_GitRepo_ssh_push(repo_path, remote_path):
from datalad import ssh_manager
remote_repo = GitRepo(remote_path, create=True)
url = "ssh://localhost" + op.abspath(remote_path)
socket_path = op.join(ssh_manager.socket_dir, get_connection_hash('localhost'))
repo = GitRepo(repo_path, create=True)
repo.add_remote("ssh-remote", url)
# modify local repo:
repo.checkout("ssh-test", ['-b'])
with open(op.join(repo.path, "ssh_testfile.dat"), "w") as f:
f.write("whatever")
repo.add("ssh_testfile.dat")
repo.commit("ssh_testfile.dat added.")
# file is not known to the remote yet:
assert_not_in("ssh_testfile.dat", remote_repo.get_indexed_files())
# push changes:
pushed = repo.push(remote="ssh-remote", refspec="ssh-test")
# test PushInfo object for
assert_in("ssh-remote/ssh-test", [commit.remote_ref.name for commit in pushed])
# the connection is known to the SSH manager, since fetch() requested it:
assert_in(socket_path, ssh_manager._connections)
# and socket was created:
ok_(op.exists(socket_path))
# remote now knows the changes:
assert_in("ssh-test", remote_repo.get_branches())
assert_in("ssh_testfile.dat", remote_repo.get_files("ssh-test"))
# amend to make it require "--force":
repo.commit("amended", options=['--amend'])
# push without --force should yield an error:
pushed = repo.push(remote="ssh-remote", refspec="ssh-test")
assert_in("[rejected] (non-fast-forward)", pushed[0].summary)
# now push using force:
repo.push(remote="ssh-remote", refspec="ssh-test", force=True)
# correct commit message in remote:
assert_in("amended",
list(remote_repo.get_branch_commits('ssh-test'))[-1].summary)