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

Getting branch,subject,status from Python-gerrit-api package

文档 link:https://python-gerrit-api.readthedocs.io/en/latest/index.html

代码:

gerrit=GerritClient(base_url="https://gerrit.xx.xxx.com",用户名='xxx',密码='xxx')

更改 = gerrit.changes.get("xxx")

问题

我从上面的代码中获取了 GerritChange 对象(更改),如何从该对象中打印状态、分支、项目等?

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

参见:https://python-gerrit-api.readthedocs.io/en/latest/_modules/gerrit/changes/change.html#GerritChange

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)