从Python gerrit api包获取分支、主题和状态

从Python gerrit api包获取分支、主题和状态,python,gerrit,Python,Gerrit,文档链接: 代码: gerrit=GerritClient(基本url=”https://gerrit.xx.xxx.com“,用户名='xxx',密码='xxx') change=gerrit.changes.get(“xxx”) 问题 我从上述代码中获取GerritChange对象(change),以及如何打印状态、分支机构、项目等。。从这个对象?这是我刚刚做的一个简单测试。看起来是个不错的api。谢谢,我可以自己用 见: 我本来想说这已经过时了,但那是pygerrit vs pygerri

文档链接:

代码:

gerrit=GerritClient(基本url=”https://gerrit.xx.xxx.com“,用户名='xxx',密码='xxx')

change=gerrit.changes.get(“xxx”)

问题


我从上述代码中获取GerritChange对象(change),以及如何打印状态、分支机构、项目等。。从这个对象?

这是我刚刚做的一个简单测试。看起来是个不错的api。谢谢,我可以自己用

见:


我本来想说这已经过时了,但那是pygerrit vs pygerrit2。。非常感谢。对于某些端点,我能够从rest api发送get响应,但是通过这个包我得到了这个错误(gerrit.utils.exceptions.NotFoundError:404客户端错误)。我能够从getrestapi获得这个url的响应:通过postman。代码:ab=change.get_revision(“32423”)print(ab.get_commit().list_change_files())我收到此代码的错误。get_revision中的参数应该是该提交的SHA-1。使用Gerrit API很难找到当前的_修订。我能找到它的唯一方法是使用搜索功能。是的,我确实使用了SHA-1,我刚才在这里提到了“否”。尽管如此,我还是收到了404客户端错误,而我能够从Rest API获得相同的响应。我问了另一个问题。请你看一下。
from gerrit import GerritClient
gerrit = GerritClient(base_url="https://gerrit.xxx.xxx", username='xxx', password='xxxx')

change = gerrit.changes.get("7268")

print (change.branch)
print (change.project)
print (change.status)
# The current_revision is not returned when loading a change
print (change.current_revision)

resultset = gerrit.changes.search("q=7268&o=CURRENT_REVISION")
change = resultset[0]

# The current_revision is returned when searching
# and adding the CURRENT_REVISION option
print (change.current_revision)

# Use the current revision to display the files
revision = change.get_revision(change.current_revision)
for f in revision.files:
  print (f)