'Getting branch,subject,status from Python-gerrit-api package
Documentation link:https://python-gerrit-api.readthedocs.io/en/latest/index.html
Code:
gerrit=GerritClient(base_url="https://gerrit.xx.xxx.com",username='xxx',password='xxx')
change = gerrit.changes.get("xxx")
Question
I get the GerritChange object(change) from the above code and how do I print status, branch, project, etc.. from this object?
Solution 1:[1]
This is a simple test I just did. Looks like a nice api. Thanks, may use it myself.
See: 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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |