diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 5faa59c5a..64c9a994b 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -345,7 +345,7 @@ Args: Returns: the name of the branch -— **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):** +— **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 + +— **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] diff --git a/recipes/recipe_modules/gerrit/api.py b/recipes/recipe_modules/gerrit/api.py index 3f97d4848..939b37076 100644 --- a/recipes/recipe_modules/gerrit/api.py +++ b/recipes/recipe_modules/gerrit/api.py @@ -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' % (