mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Add a 'setlabel' command to gerrit_client.py
And add a hook for it in the gerrit recipe_module. This will allow invocations of gerrit_client to set votes like "code-review-1" or "commit-queue+1" on CLs. This will be used by bots to control CLs they just created with update_files(). Bug: 1250084 Change-Id: I888458983165fed5882e5c37cba4a69dbfb9b810 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3207266 Commit-Queue: Ben Pastene <bpastene@chromium.org> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
@@ -226,6 +226,24 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
step_test_data=step_test_data,
|
||||
).json.output
|
||||
|
||||
def set_change_label(self,
|
||||
host,
|
||||
change,
|
||||
label_name,
|
||||
label_value,
|
||||
name=None,
|
||||
step_test_data=None):
|
||||
args = [
|
||||
'setlabel', '--host', host, '--change',
|
||||
int(change), '--json_file',
|
||||
self.m.json.output(), '-l', label_name, label_value
|
||||
]
|
||||
return self(
|
||||
name or 'setlabel',
|
||||
args,
|
||||
step_test_data=step_test_data,
|
||||
).json.output
|
||||
|
||||
def move_changes(self,
|
||||
host,
|
||||
project,
|
||||
|
||||
@@ -450,6 +450,60 @@
|
||||
"@@@STEP_LOG_END@json.output@@@"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"vpython",
|
||||
"-u",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"setlabel",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--change",
|
||||
"123",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json",
|
||||
"-l",
|
||||
"code-review",
|
||||
"-1"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
},
|
||||
"infra_step": true,
|
||||
"name": "gerrit setlabel",
|
||||
"~followup_annotations": [
|
||||
"@@@STEP_LOG_END@json.output (invalid)@@@",
|
||||
"@@@STEP_LOG_LINE@json.output (exception)@No JSON object could be decoded@@@",
|
||||
"@@@STEP_LOG_END@json.output (exception)@@@"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"vpython",
|
||||
"-u",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"setlabel",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--change",
|
||||
"123",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json",
|
||||
"-l",
|
||||
"commit-queue",
|
||||
"1"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
},
|
||||
"infra_step": true,
|
||||
"name": "gerrit setlabel (2)",
|
||||
"~followup_annotations": [
|
||||
"@@@STEP_LOG_END@json.output (invalid)@@@",
|
||||
"@@@STEP_LOG_LINE@json.output (exception)@No JSON object could be decoded@@@",
|
||||
"@@@STEP_LOG_END@json.output (exception)@@@"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"vpython",
|
||||
|
||||
@@ -65,6 +65,9 @@ def RunSteps(api):
|
||||
api.gerrit.get_change_description(
|
||||
host, change=123, patchset=1)
|
||||
|
||||
api.gerrit.set_change_label(host, 123, 'code-review', -1)
|
||||
api.gerrit.set_change_label(host, 123, 'commit-queue', 1)
|
||||
|
||||
api.gerrit.abandon_change(host, 123, 'bad roll')
|
||||
|
||||
with api.step.defer_results():
|
||||
|
||||
Reference in New Issue
Block a user