Commit 1f156687 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

gerrit/api.py: Add get_revision() helper.

Allows easily getting at more than just the commit message.
I intend to look at the author to whitelist bots from binary size
checks (initially).

Bug: 702625
Change-Id: I684fdfacc88635ec4849216c74183f63f9d54810
Reviewed-on: https://chromium-review.googlesource.com/1070483
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
parent ebdd0db4
......@@ -345,7 +345,7 @@ Args:
Returns:
the name of the branch
&mdash; **def [get\_changes](/recipes/recipe_modules/gerrit/api.py#135)(self, host, query_params, start=None, limit=None, o_params=None, step_test_data=None, \*\*kwargs):**
&mdash; **def [get\_changes](/recipes/recipe_modules/gerrit/api.py#151)(self, host, query_params, start=None, limit=None, o_params=None, step_test_data=None, \*\*kwargs):**
Query changes for the given host.
......@@ -369,6 +369,19 @@ Get a branch from given project and commit
Returns:
the revision of the branch
&mdash; **def [get\_revision\_info](/recipes/recipe_modules/gerrit/api.py#121)(self, host, change, patchset):**
Returns the info for a given patchset of a given change.
Args:
host: Gerrit host to query.
change: The change number.
patchset: The patchset number.
Returns:
A dict for the target revision as documented here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes
### *recipe_modules* / [git](/recipes/recipe_modules/git)
[DEPS](/recipes/recipe_modules/git/__init__.py#1): [infra\_paths](#recipe_modules-infra_paths), [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
......
......@@ -115,6 +115,22 @@ class GerritApi(recipe_api.RecipeApi):
Returns:
The description corresponding to given CL and patchset.
"""
ri = self.get_revision_info(host, change, patchset)
return ri['commit']['message']
def get_revision_info(self, host, change, patchset):
"""
Returns the info for a given patchset of a given change.
Args:
host: Gerrit host to query.
change: The change number.
patchset: The patchset number.
Returns:
A dict for the target revision as documented here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes
"""
assert int(change), change
assert int(patchset), patchset
cls = self.get_changes(
......@@ -126,7 +142,7 @@ class GerritApi(recipe_api.RecipeApi):
for ri in cl['revisions'].itervalues():
# TODO(tandrii): add support for patchset=='current'.
if str(ri['_number']) == str(patchset):
return ri['commit']['message']
return ri
raise self.m.step.InfraFailure(
'Error querying for CL description: host:%r change:%r; patchset:%r' % (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment