diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 11c7c4720..ad8130766 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -446,7 +446,7 @@ Returns: — **def [move\_changes](/recipes/recipe_modules/gerrit/api.py#229)(self, host, project, from_branch, to_branch, step_test_data=None):** -— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#253)(self, host, project, branch, new_contents_by_file_path, commit_msg, submit=False):** +— **def [update\_files](/recipes/recipe_modules/gerrit/api.py#253)(self, host, project, branch, new_contents_by_file_path, commit_msg, params=frozenset(['status=NEW']), submit=False):** Update a set of files by creating and submitting a Gerrit CL. @@ -457,6 +457,8 @@ Args: * new_contents_by_file_path: Dict of the new contents with file path as the key. * commit_msg: Description to add to the CL. + * params: A list of additional ChangeInput specifiers, with format + 'key=value'. * submit: Should land this CL instantly. Returns: diff --git a/recipes/recipe_modules/gerrit/api.py b/recipes/recipe_modules/gerrit/api.py index ab2ef9cf0..93e9b5d40 100644 --- a/recipes/recipe_modules/gerrit/api.py +++ b/recipes/recipe_modules/gerrit/api.py @@ -256,6 +256,7 @@ class GerritApi(recipe_api.RecipeApi): branch, new_contents_by_file_path, commit_msg, + params=frozenset(['status=NEW']), submit=False): """Update a set of files by creating and submitting a Gerrit CL. @@ -266,6 +267,8 @@ class GerritApi(recipe_api.RecipeApi): * new_contents_by_file_path: Dict of the new contents with file path as the key. * commit_msg: Description to add to the CL. + * params: A list of additional ChangeInput specifiers, with format + 'key=value'. * submit: Should land this CL instantly. Returns: @@ -273,7 +276,7 @@ class GerritApi(recipe_api.RecipeApi): """ assert len(new_contents_by_file_path ) > 0, 'The dict of file paths should not be empty.' - step_result = self('create change at (%s %s)' % (project, branch), [ + command = [ 'createchange', '--host', host, @@ -285,7 +288,10 @@ class GerritApi(recipe_api.RecipeApi): commit_msg, '--json_file', self.m.json.output(), - ]) + ] + for p in params: + command.extend(['-p', p]) + 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' % change] = '%s/#/q/%d' % (host, change) diff --git a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json index ea0c9883e..22a00a71e 100644 --- a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +++ b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json @@ -121,7 +121,9 @@ "--subject", "Dummy CL.", "--json_file", - "/path/to/tmp/json" + "/path/to/tmp/json", + "-p", + "status=NEW" ], "env": { "PATH": ":RECIPE_REPO[depot_tools]"