Commit a992238b authored by Xinan Lin's avatar Xinan Lin Committed by LUCI CQ

Add params to update_files method

params in the form 'key=value' is required by gerrit_client tool,
although may not be used by the backend.

BUG=1207955
TEST=e2e

Recipe-Nontrivial-Roll: chrome_release
Change-Id: I1181868060af921f87efe55ea9f60fa37ae8b215
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3068823
Commit-Queue: Xinan Lin <linxinan@chromium.org>
Reviewed-by: 's avatarMichael Moss <mmoss@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@google.com>
parent 248a70bd
......@@ -446,7 +446,7 @@ Returns:
&mdash; **def [move\_changes](/recipes/recipe_modules/gerrit/api.py#229)(self, host, project, from_branch, to_branch, step_test_data=None):**
&mdash; **def [update\_files](/recipes/recipe_modules/gerrit/api.py#253)(self, host, project, branch, new_contents_by_file_path, commit_msg, submit=False):**
&mdash; **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:
......
......@@ -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)
......
......@@ -121,7 +121,9 @@
"--subject",
"Dummy CL.",
"--json_file",
"/path/to/tmp/json"
"/path/to/tmp/json",
"-p",
"status=NEW"
],
"env": {
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment