Return changeinfo from update_files method

Users may need more info from a created/submitted change,
e.g. revision hash, change status(submitted or not) etc.

BUG=1236658
TEST=train
Recipe-Nontrivial-Roll: chrome_release
Change-Id: I1db57e5c6a4e58ea320526ef5f5cbb83e1b0bb60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3102579
Commit-Queue: Xinan Lin <linxinan@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
Reviewed-by: Michael Moss <mmoss@chromium.org>
changes/79/3102579/16
Xinan Lin 4 years ago committed by LUCI CQ
parent 21a20d6895
commit f9d9909c10

@ -462,7 +462,10 @@ Args:
* submit: Should land this CL instantly. * submit: Should land this CL instantly.
Returns: Returns:
Integer change number. A ChangeInfo dictionary as documented here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#create-change
Or if the change is submitted, here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#submit-change
### *recipe_modules* / [git](/recipes/recipe_modules/git) ### *recipe_modules* / [git](/recipes/recipe_modules/git)
[DEPS](/recipes/recipe_modules/git/__init__.py#1): [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step] [DEPS](/recipes/recipe_modules/git/__init__.py#1): [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step]

@ -272,7 +272,10 @@ class GerritApi(recipe_api.RecipeApi):
* submit: Should land this CL instantly. * submit: Should land this CL instantly.
Returns: Returns:
Integer change number. A ChangeInfo dictionary as documented here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#create-change
Or if the change is submitted, here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#submit-change
""" """
assert len(new_contents_by_file_path assert len(new_contents_by_file_path
) > 0, 'The dict of file paths should not be empty.' ) > 0, 'The dict of file paths should not be empty.'
@ -329,11 +332,14 @@ class GerritApi(recipe_api.RecipeApi):
'--change', '--change',
change, change,
]) ])
self('submit change %d' % change, [ submit_cmd = [
'submitchange', 'submitchange',
'--host', '--host',
host, host,
'--change', '--change',
change, change,
]) '--json_file',
return change self.m.json.output(),
]
step_result = self('submit change %d' % change, submit_cmd)
return step_result.json.output

@ -138,6 +138,14 @@
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@", "@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@", "@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@", "@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"_number\": \"1\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"commit\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"message\": \"Change commit message\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"status\": \"NEW\", @@@", "@@@STEP_LOG_LINE@json.output@ \"status\": \"NEW\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"subject\": \"Change title\"@@@", "@@@STEP_LOG_LINE@json.output@ \"subject\": \"Change title\"@@@",
"@@@STEP_LOG_LINE@json.output@}@@@", "@@@STEP_LOG_LINE@json.output@}@@@",
@ -235,13 +243,36 @@
"--host", "--host",
"https://chromium-review.googlesource.com", "https://chromium-review.googlesource.com",
"--change", "--change",
"91827" "91827",
"--json_file",
"/path/to/tmp/json"
], ],
"env": { "env": {
"PATH": "<PATH>:RECIPE_REPO[depot_tools]" "PATH": "<PATH>:RECIPE_REPO[depot_tools]"
}, },
"infra_step": true, "infra_step": true,
"name": "gerrit submit change 91827" "name": "gerrit submit change 91827",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"branch\": \"main\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"has_review_started\": false, @@@",
"@@@STEP_LOG_LINE@json.output@ \"project\": \"chromium/src\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"_number\": \"1\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"commit\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"message\": \"Change commit message\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"status\": \"MERGED\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"subject\": \"Change title\"@@@",
"@@@STEP_LOG_LINE@json.output@}@@@",
"@@@STEP_LOG_END@json.output@@@"
]
}, },
{ {
"cmd": [ "cmd": [

@ -23,12 +23,14 @@ def RunSteps(api):
api.gerrit.move_changes(host, project, 'master', 'main') api.gerrit.move_changes(host, project, 'master', 'main')
change = api.gerrit.update_files(host, change_info = api.gerrit.update_files(host,
project, project,
'main', {'chrome/VERSION': '99.99.99.99'}, 'main',
'Dummy CL.', {'chrome/VERSION': '99.99.99.99'},
submit=True) 'Dummy CL.',
assert change == 91827, change submit=True)
assert int(change_info['_number']) == 91827, change_info
assert change_info['status'] == 'MERGED'
# Query for changes in Chromium's CQ. # Query for changes in Chromium's CQ.
api.gerrit.get_changes( api.gerrit.get_changes(
@ -72,17 +74,18 @@ def RunSteps(api):
def GenTests(api): def GenTests(api):
yield ( yield (api.test('basic') +
api.test('basic') + api.step_data('gerrit create_gerrit_branch (v8/v8 test)',
api.step_data('gerrit create_gerrit_branch (v8/v8 test)', api.gerrit.make_gerrit_create_branch_response_data()) +
api.gerrit.make_gerrit_create_branch_response_data()) + api.step_data('gerrit create change at (v8/v8 main)',
api.step_data('gerrit create change at (v8/v8 main)', api.gerrit.update_files_response_data()) +
api.gerrit.update_files_response_data()) + api.step_data('gerrit submit change 91827',
api.step_data('gerrit get_gerrit_branch (v8/v8 main)', api.gerrit.update_files_response_data(status='MERGED')) +
api.gerrit.make_gerrit_get_branch_response_data()) + api.step_data('gerrit get_gerrit_branch (v8/v8 main)',
api.step_data('gerrit move changes', api.gerrit.make_gerrit_get_branch_response_data()) +
api.gerrit.get_move_change_response_data(branch='main')) + api.step_data('gerrit move changes',
api.step_data('gerrit relatedchanges', api.gerrit.get_move_change_response_data(branch='main'))
api.gerrit.get_related_changes_response_data()) + + api.step_data('gerrit relatedchanges',
api.step_data('gerrit changes empty query', api.gerrit.get_related_changes_response_data()) +
api.gerrit.get_empty_changes_response_data())) api.step_data('gerrit changes empty query',
api.gerrit.get_empty_changes_response_data()))

@ -80,9 +80,7 @@ class GerritTestApi(recipe_test_api.RecipeTestApi):
return self._make_gerrit_response_json([self._gerrit_change_data(**kwargs)]) return self._make_gerrit_response_json([self._gerrit_change_data(**kwargs)])
def update_files_response_data(self, **kwargs): def update_files_response_data(self, **kwargs):
data = self._gerrit_change_data(**kwargs) return self._make_gerrit_response_json(self._gerrit_change_data(**kwargs))
data.pop('revisions')
return self._make_gerrit_response_json(data)
def get_empty_changes_response_data(self): def get_empty_changes_response_data(self):
return self._make_gerrit_response_json([]) return self._make_gerrit_response_json([])

Loading…
Cancel
Save