简体   繁体   English

如何从git.push()获取Gerrit链接

[英]How to get gerrit link from git.push()

The below code pushes the change and creates gerrit, but it doesn't print the gerrit URL 下面的代码推送更改并创建Gerrit,但不会打印Gerrit URL

import sh
from sh import git
git.add(file1.txt)
gitdir=git('rev-parse', '--git-dir')
sh.scp("-p","-P",port,user+"@"+ghost+":hooks/commit-msg",str(gitdir.rstrip())+"/hooks/")
git.commit(m='my commit message')
print(git.push('origin','HEAD:refs/for/master'))

The git.push command doesn't print anything though it successfully creates a gerrit, how to get the gerrit link after it pushes? git.push命令虽然成功创建了gerrit,但没有打印任何内容,在推送后如何获取gerrit链接?

foo=git.push('origin','HEAD:refs/for/master')
output=foo.stderr.split() #Gerrit returns logs including the url to the standard error

Then you can get the url from the list output if the push is successful. 然后,如果推送成功,则可以从列表output获取URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM