diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 45a0ca3cbe..45acef9309 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -285,7 +285,7 @@ Wrapper for easy calling of gerrit_utils steps. — **def [abandon\_change](/recipes/recipe_modules/gerrit/api.py#262)(self, host, change, message=None, name=None, step_test_data=None):** -— **def [add\_message](/recipes/recipe_modules/gerrit/api.py#320)(self, host: str, change: int, message: str, revision: (str | int)='current', step_name: str=None, step_test_data: (Callable[([], StepTestData)] | None)=None):** +— **def [add\_message](/recipes/recipe_modules/gerrit/api.py#320)(self, host: str, change: int, message: str, revision: (str | int)='current', automatic_attention_set_update: Optional[bool]=None, step_name: str=None, step_test_data: (Callable[([], StepTestData)] | None)=None):** Add a message to a change at given revision. @@ -298,6 +298,7 @@ Args: documented here: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#revision-id This defaults to current, which names the most recent patchset. + * automatic_attention_set_update: Whether to update the attention set. * step_name: Optional step name. * step_test_data: Optional mock test data for the underlying gerrit client. @@ -393,13 +394,13 @@ Returns: A dict for the target revision as documented here: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes -— **def [move\_changes](/recipes/recipe_modules/gerrit/api.py#357)(self, host, project, from_branch, to_branch, step_test_data=None):** +— **def [move\_changes](/recipes/recipe_modules/gerrit/api.py#364)(self, host, project, from_branch, to_branch, step_test_data=None):** — **def [restore\_change](/recipes/recipe_modules/gerrit/api.py#282)(self, host, change, message=None, name=None, step_test_data=None):** — **def [set\_change\_label](/recipes/recipe_modules/gerrit/api.py#302)(self, host, change, label_name, label_value, name=None, step_test_data=None):** -— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#381)(self, host, project, branch, new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), cc_list=frozenset([]), submit=False, submit_later=False, step_test_data_create_change=None, step_test_data_submit_change=None):** +— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#388)(self, host, project, branch, new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), cc_list=frozenset([]), submit=False, submit_later=False, step_test_data_create_change=None, step_test_data_submit_change=None):** Update a set of files by creating and submitting a Gerrit CL. diff --git a/recipes/recipe_modules/gerrit/api.py b/recipes/recipe_modules/gerrit/api.py index 60edc019c7..f370dc3e31 100644 --- a/recipes/recipe_modules/gerrit/api.py +++ b/recipes/recipe_modules/gerrit/api.py @@ -4,7 +4,7 @@ from recipe_engine import recipe_api from recipe_engine.recipe_test_api import StepTestData -from typing import Callable +from typing import Callable, Optional class GerritApi(recipe_api.RecipeApi): """Module for interact with Gerrit endpoints""" @@ -323,6 +323,7 @@ class GerritApi(recipe_api.RecipeApi): change: int, message: str, revision: str | int = 'current', + automatic_attention_set_update: Optional[bool] = None, step_name: str = None, step_test_data: Callable[[], StepTestData] | None = None) -> None: """Add a message to a change at given revision. @@ -336,6 +337,7 @@ class GerritApi(recipe_api.RecipeApi): documented here: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#revision-id This defaults to current, which names the most recent patchset. + * automatic_attention_set_update: Whether to update the attention set. * step_name: Optional step name. * step_test_data: Optional mock test data for the underlying gerrit client. @@ -346,6 +348,11 @@ class GerritApi(recipe_api.RecipeApi): str(revision), '--message', message, '--json_file', self.m.json.output() ] + if automatic_attention_set_update is not None: + args += [ + '--automatic-attention-set-update' if automatic_attention_set_update + else '--no-automatic-attention-set-update' + ] if not step_test_data: step_test_data = lambda: self.m.json.test_api.output({}) return self( diff --git a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json index 472b89d4b2..3bc35871a2 100644 --- a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +++ b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json @@ -652,6 +652,33 @@ "@@@STEP_LOG_END@json.output (exception)@@@" ] }, + { + "cmd": [ + "vpython3", + "RECIPE_REPO[depot_tools]/gerrit_client.py", + "addmessage", + "--host", + "https://chromium-review.googlesource.com", + "--change", + "123", + "--revision", + "current", + "--message", + "This is a non-attention message", + "--json_file", + "/path/to/tmp/json", + "--no-automatic-attention-set-update" + ], + "env": { + "PATH": ":RECIPE_REPO[depot_tools]" + }, + "infra_step": true, + "name": "gerrit add message", + "~followup_annotations": [ + "@@@STEP_LOG_LINE@json.output@{}@@@", + "@@@STEP_LOG_END@json.output@@@" + ] + }, { "cmd": [ "vpython3", @@ -672,7 +699,7 @@ "PATH": ":RECIPE_REPO[depot_tools]" }, "infra_step": true, - "name": "gerrit add message", + "name": "gerrit add message (2)", "~followup_annotations": [ "@@@STEP_LOG_LINE@json.output@{}@@@", "@@@STEP_LOG_END@json.output@@@" diff --git a/recipes/recipe_modules/gerrit/examples/full.py b/recipes/recipe_modules/gerrit/examples/full.py index fe57f61fa8..bf7d3ca657 100644 --- a/recipes/recipe_modules/gerrit/examples/full.py +++ b/recipes/recipe_modules/gerrit/examples/full.py @@ -88,6 +88,10 @@ def RunSteps(api): api.gerrit.set_change_label(host, 123, 'code-review', -1) api.gerrit.set_change_label(host, 123, 'commit-queue', 1) + api.gerrit.add_message(host, + 123, + 'This is a non-attention message', + automatic_attention_set_update=False) api.gerrit.add_message(host, 123, 'This is a comment message') api.gerrit.abandon_change(host, 123, 'bad roll')