diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index f8a4a616ae..b821e42d06 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -349,7 +349,7 @@ Returns: — **def [set\_change\_label](/recipes/recipe_modules/gerrit/api.py#277)(self, host, change, label_name, label_value, name=None, step_test_data=None):** -— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#319)(self, host, project, branch, new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), submit=False, submit_later=False):** +— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#319)(self, host, project, branch, new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), cc_list=frozenset([]), submit=False, submit_later=False):** Update a set of files by creating and submitting a Gerrit CL. @@ -362,6 +362,7 @@ Args: * commit_msg: Description to add to the CL. * params: A list of additional ChangeInput specifiers, with format 'key=value'. + * cc_list: A list of addresses to notify. * submit: Should land this CL instantly. * submit_later: If this change has related CLs, we may want to commit them in a chain. So only set Bot-Commit+1, making it ready for diff --git a/recipes/recipe_modules/gerrit/api.py b/recipes/recipe_modules/gerrit/api.py index ca9ef2172a..972526525f 100644 --- a/recipes/recipe_modules/gerrit/api.py +++ b/recipes/recipe_modules/gerrit/api.py @@ -323,6 +323,7 @@ class GerritApi(recipe_api.RecipeApi): new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), + cc_list=frozenset([]), submit=False, submit_later=False): """Update a set of files by creating and submitting a Gerrit CL. @@ -336,6 +337,7 @@ class GerritApi(recipe_api.RecipeApi): * commit_msg: Description to add to the CL. * params: A list of additional ChangeInput specifiers, with format 'key=value'. + * cc_list: A list of addresses to notify. * submit: Should land this CL instantly. * submit_later: If this change has related CLs, we may want to commit them in a chain. So only set Bot-Commit+1, making it ready for @@ -364,6 +366,8 @@ class GerritApi(recipe_api.RecipeApi): ] for p in params: command.extend(['-p', p]) + for cc in cc_list: + command.extend(['--cc', cc]) step_result = self('create change at (%s %s)' % (project, branch), command) change = int(step_result.json.output.get('_number')) step_result.presentation.links['change %d' % diff --git a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json index ea2bf373a9..249b0ad9e6 100644 --- a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +++ b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json @@ -187,7 +187,9 @@ "--json_file", "/path/to/tmp/json", "-p", - "status=NEW" + "status=NEW", + "--cc", + "foo@example.com" ], "env": { "PATH": ":RECIPE_REPO[depot_tools]" diff --git a/recipes/recipe_modules/gerrit/examples/full.py b/recipes/recipe_modules/gerrit/examples/full.py index e31ae4245f..d40fc064db 100644 --- a/recipes/recipe_modules/gerrit/examples/full.py +++ b/recipes/recipe_modules/gerrit/examples/full.py @@ -44,7 +44,8 @@ def RunSteps(api): 'main', {'chrome/VERSION': '99.99.99.99'}, 'Dummy CL.', - submit=True) + submit=True, + cc_list=['foo@example.com']) assert int(change_info['_number']) == 91827, change_info assert change_info['status'] == 'MERGED'