从Pythongerritapi包获取分支、主题和状态

2024-04-27 03:33:22 发布

您现在位置:Python中文网/ 问答频道 /正文

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

代码:

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

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

问题

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


Tags: 代码文档httpsioapiindex链接html
1条回答
网友
1楼 · 发布于 2024-04-27 03:33:22

这是我刚刚做的一个简单测试。看起来是个不错的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)

相关问题 更多 >