diff --git a/gerrit_client.py b/gerrit_client.py index 45150b6fd2..9634c49fbf 100755 --- a/gerrit_client.py +++ b/gerrit_client.py @@ -383,9 +383,18 @@ def CMDgetcommitincludedin(parser, args): def CMDsetbotcommit(parser, args): """Sets bot-commit+1 to a bot generated change.""" parser.add_option('-c', '--change', type=int, help='change number') + parser.add_option( + '-r', + '--revision', + type=str, + default='current', + help='revision ID. See ' + 'https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#revision-id ' # pylint: disable=line-too-long + 'for acceptable format') (opt, args) = parser.parse_args(args) result = gerrit_util.SetReview(urllib.parse.urlparse(opt.host).netloc, opt.change, + opt.revision, labels={'Bot-Commit': 1}, ready=True) logging.info(result) diff --git a/recipes/recipe_modules/gerrit/api.py b/recipes/recipe_modules/gerrit/api.py index 0db01e96bd..1d0e7dae8b 100644 --- a/recipes/recipe_modules/gerrit/api.py +++ b/recipes/recipe_modules/gerrit/api.py @@ -558,13 +558,16 @@ class GerritApi(recipe_api.RecipeApi): publish_command.append('--verbose') self('publish edit', publish_command) + NEW_PATCHSET_REVISION_NUMBER = 2 # Make sure the new patchset is propagated to Gerrit backend. with self.m.step.nest('verify the patchset exists on CL %d' % change): retries = 0 max_retries = 2 while retries <= max_retries: try: - if self.get_revision_info(host, change, 2): + if self.get_revision_info(host, + change, + patchset=NEW_PATCHSET_REVISION_NUMBER): break except self.m.step.InfraFailure: if retries == max_retries: # pragma: no cover @@ -580,6 +583,8 @@ class GerritApi(recipe_api.RecipeApi): host, '--change', change, + '--revision', + NEW_PATCHSET_REVISION_NUMBER, ] if verbose: set_bot_commit_command.append('--verbose') diff --git a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json index db44e40ba4..64c0c995c7 100644 --- a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +++ b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json @@ -384,6 +384,8 @@ "https://chromium-review.googlesource.com", "--change", "91827", + "--revision", + "2", "--verbose" ], "env": {