Add 'create tag' support to gerrit_client and gerrit recipe_module.

BUG=1052179
R=dpranke@google.com, linxinan@chromium.org

Change-Id: I6e220b70e63d990e9257d9fe4d107de7dbd2eb81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3232849
Auto-Submit: Michael Moss <mmoss@chromium.org>
Commit-Queue: Michael Moss <mmoss@chromium.org>
Reviewed-by: Xinan Lin <linxinan@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
This commit is contained in:
Michael Moss
2021-10-20 04:36:24 +00:00
committed by LUCI CQ
parent bec0d0fdd0
commit b6ce244503
7 changed files with 115 additions and 9 deletions

View File

@@ -48,6 +48,25 @@ class GerritApi(recipe_api.RecipeApi):
ref = step_result.json.output.get('ref')
return ref
def create_gerrit_tag(self, host, project, tag, commit, **kwargs):
"""Creates a new tag at the given commit.
Returns:
The ref of the tag created.
"""
args = [
'tag',
'--host', host,
'--project', project,
'--tag', tag,
'--commit', commit,
'--json_file', self.m.json.output()
]
step_name = 'create_gerrit_tag (%s %s)' % (project, tag)
step_result = self(step_name, args, **kwargs)
ref = step_result.json.output.get('ref')
return ref
# TODO(machenbach): Rename to get_revision? And maybe above to
# create_ref?
def get_gerrit_branch(self, host, project, branch, **kwargs):