mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Add verbose parameter to Gerrit recipe API.
Verbose logging is disabled by default in all functions except get_changes and the caller functions, since get_changes is already using verbose logging. Bug: 402142151 Change-Id: Ifb4d62b215ded8f7be21217f2579574ea4d211f6 Recipe-Nontrivial-Roll: build Recipe-Nontrivial-Roll: build_internal Recipe-Nontrivial-Roll: chromiumos Recipe-Nontrivial-Roll: infra Recipe-Manual-Change: chrome_release Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6341791 Commit-Queue: Keybo Qian <keybo@google.com> Reviewed-by: Adarsh Murthy <adarshmurthy@google.com> Reviewed-by: Scott Lee <ddoman@chromium.org>
This commit is contained in:
@@ -37,6 +37,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
body=None,
|
||||
accept_statuses=None,
|
||||
name=None,
|
||||
verbose=False,
|
||||
**kwargs):
|
||||
"""Call an arbitrary Gerrit API that returns a JSON response.
|
||||
|
||||
@@ -54,12 +55,20 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
if accept_statuses:
|
||||
args.extend(
|
||||
['--accept_status', ','.join(str(i) for i in accept_statuses)])
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
|
||||
step_name = name or 'call_raw_api (%s)' % path
|
||||
step_result = self(step_name, args, **kwargs)
|
||||
return step_result.json.output
|
||||
|
||||
def create_gerrit_branch(self, host, project, branch, commit, **kwargs):
|
||||
def create_gerrit_branch(self,
|
||||
host,
|
||||
project,
|
||||
branch,
|
||||
commit,
|
||||
verbose=False,
|
||||
**kwargs):
|
||||
"""Creates a new branch from given project and commit
|
||||
|
||||
Returns:
|
||||
@@ -76,12 +85,20 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
allow_existent_branch = kwargs.pop('allow_existent_branch', False)
|
||||
if allow_existent_branch:
|
||||
args.append('--allow-existent-branch')
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
step_name = 'create_gerrit_branch (%s %s)' % (project, branch)
|
||||
step_result = self(step_name, args, **kwargs)
|
||||
ref = step_result.json.output.get('ref')
|
||||
return ref
|
||||
|
||||
def create_gerrit_tag(self, host, project, tag, commit, **kwargs):
|
||||
def create_gerrit_tag(self,
|
||||
host,
|
||||
project,
|
||||
tag,
|
||||
commit,
|
||||
verbose=False,
|
||||
**kwargs):
|
||||
"""Creates a new tag at the given commit.
|
||||
|
||||
Returns:
|
||||
@@ -95,6 +112,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
'--commit', commit,
|
||||
'--json_file', self.m.json.output()
|
||||
]
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
step_name = 'create_gerrit_tag (%s %s)' % (project, tag)
|
||||
step_result = self(step_name, args, **kwargs)
|
||||
ref = step_result.json.output.get('ref')
|
||||
@@ -102,7 +121,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
|
||||
# TODO(machenbach): Rename to get_revision? And maybe above to
|
||||
# create_ref?
|
||||
def get_gerrit_branch(self, host, project, branch, **kwargs):
|
||||
def get_gerrit_branch(self, host, project, branch, verbose=False, **kwargs):
|
||||
"""Gets a branch from given project and commit
|
||||
|
||||
Returns:
|
||||
@@ -115,6 +134,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
'--branch', branch,
|
||||
'--json_file', self.m.json.output()
|
||||
]
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
step_name = 'get_gerrit_branch (%s %s)' % (project, branch)
|
||||
step_result = self(step_name, args, **kwargs)
|
||||
revision = step_result.json.output.get('revision')
|
||||
@@ -125,18 +146,21 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
change,
|
||||
patchset,
|
||||
timeout=None,
|
||||
step_test_data=None):
|
||||
step_test_data=None,
|
||||
verbose=True):
|
||||
"""Gets the description for a given CL and patchset.
|
||||
|
||||
Args:
|
||||
host: URL of Gerrit host to query.
|
||||
change: The change number.
|
||||
patchset: The patchset number.
|
||||
verbose: Whether to enable verbose logging.
|
||||
|
||||
Returns:
|
||||
The description corresponding to given CL and patchset.
|
||||
"""
|
||||
ri = self.get_revision_info(host, change, patchset, timeout, step_test_data)
|
||||
ri = self.get_revision_info(host, change, patchset, timeout, step_test_data,
|
||||
verbose)
|
||||
return ri['commit']['message']
|
||||
|
||||
def get_revision_info(self,
|
||||
@@ -144,7 +168,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
change,
|
||||
patchset,
|
||||
timeout=None,
|
||||
step_test_data=None):
|
||||
step_test_data=None,
|
||||
verbose=True):
|
||||
"""
|
||||
Returns the info for a given patchset of a given change.
|
||||
|
||||
@@ -152,6 +177,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
host: Gerrit host to query.
|
||||
change: The change number.
|
||||
patchset: The patchset number.
|
||||
verbose: Whether to enable verbose logging.
|
||||
|
||||
Returns:
|
||||
A dict for the target revision as documented here:
|
||||
@@ -169,7 +195,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
o_params=['ALL_REVISIONS', 'ALL_COMMITS'],
|
||||
limit=1,
|
||||
timeout=timeout,
|
||||
step_test_data=step_test_data)
|
||||
step_test_data=step_test_data,
|
||||
verbose=verbose)
|
||||
cl = cls[0] if len(cls) == 1 else {'revisions': {}}
|
||||
for ri in cl['revisions'].values():
|
||||
# TODO(tandrii): add support for patchset=='current'.
|
||||
@@ -180,8 +207,15 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
'Error querying for CL description: host:%r change:%r; patchset:%r' % (
|
||||
host, change, patchset))
|
||||
|
||||
def get_changes(self, host, query_params, start=None, limit=None,
|
||||
o_params=None, step_test_data=None, **kwargs):
|
||||
def get_changes(self,
|
||||
host,
|
||||
query_params,
|
||||
start=None,
|
||||
limit=None,
|
||||
o_params=None,
|
||||
step_test_data=None,
|
||||
verbose=True,
|
||||
**kwargs):
|
||||
"""Queries changes for the given host.
|
||||
|
||||
Args:
|
||||
@@ -194,6 +228,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
* o_params: A list of additional output specifiers, as documented here:
|
||||
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes
|
||||
* step_test_data: Optional mock test data for the underlying gerrit client.
|
||||
* verbose: Whether to enable verbose logging.
|
||||
|
||||
Returns:
|
||||
A list of change dicts as documented here:
|
||||
@@ -201,7 +236,6 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
"""
|
||||
args = [
|
||||
'changes',
|
||||
'--verbose',
|
||||
'--host', host,
|
||||
'--json_file', self.m.json.output()
|
||||
]
|
||||
@@ -213,6 +247,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
args += ['-p', '%s=%s' % (k, v)]
|
||||
for v in (o_params or []):
|
||||
args += ['-o', v]
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
if not step_test_data:
|
||||
step_test_data = lambda: self.test_api.get_one_change_response_data()
|
||||
|
||||
@@ -223,7 +259,12 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
**kwargs
|
||||
).json.output
|
||||
|
||||
def get_related_changes(self, host, change, revision='current', step_test_data=None):
|
||||
def get_related_changes(self,
|
||||
host,
|
||||
change,
|
||||
revision='current',
|
||||
step_test_data=None,
|
||||
verbose=False):
|
||||
"""Queries related changes for a given host, change, and revision.
|
||||
|
||||
Args:
|
||||
@@ -236,6 +277,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#revision-id
|
||||
This defaults to current, which names the most recent patch set.
|
||||
* step_test_data: Optional mock test data for the underlying gerrit client.
|
||||
* verbose: Whether to enable verbose logging.
|
||||
|
||||
Returns:
|
||||
A related changes dictionary as documented here:
|
||||
@@ -253,14 +295,21 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
'--json_file',
|
||||
self.m.json.output(),
|
||||
]
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
if not step_test_data:
|
||||
step_test_data = lambda: self.test_api.get_related_changes_response_data()
|
||||
|
||||
return self('relatedchanges', args,
|
||||
step_test_data=step_test_data).json.output
|
||||
|
||||
def abandon_change(self, host, change, message=None, name=None,
|
||||
step_test_data=None):
|
||||
def abandon_change(self,
|
||||
host,
|
||||
change,
|
||||
message=None,
|
||||
name=None,
|
||||
step_test_data=None,
|
||||
verbose=False):
|
||||
args = [
|
||||
'abandon',
|
||||
'--host', host,
|
||||
@@ -269,6 +318,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
]
|
||||
if message:
|
||||
args.extend(['--message', message])
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
if not step_test_data:
|
||||
step_test_data = lambda: self.test_api.get_one_change_response_data(
|
||||
status='ABANDONED', _number=str(change))
|
||||
@@ -279,8 +330,13 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
step_test_data=step_test_data,
|
||||
).json.output
|
||||
|
||||
def restore_change(self, host, change, message=None, name=None,
|
||||
step_test_data=None):
|
||||
def restore_change(self,
|
||||
host,
|
||||
change,
|
||||
message=None,
|
||||
name=None,
|
||||
step_test_data=None,
|
||||
verbose=False):
|
||||
args = [
|
||||
'restore',
|
||||
'--host', host,
|
||||
@@ -289,6 +345,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
]
|
||||
if message:
|
||||
args.extend(('--message', message))
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
if not step_test_data:
|
||||
step_test_data = lambda: self.test_api.get_one_change_response_data(
|
||||
status='NEW', _number=str(change))
|
||||
@@ -305,12 +363,15 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
label_name,
|
||||
label_value,
|
||||
name=None,
|
||||
step_test_data=None):
|
||||
step_test_data=None,
|
||||
verbose=False):
|
||||
args = [
|
||||
'setlabel', '--host', host, '--change',
|
||||
int(change), '--json_file',
|
||||
self.m.json.output(), '-l', label_name, label_value
|
||||
]
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
return self(
|
||||
name or 'setlabel',
|
||||
args,
|
||||
@@ -325,7 +386,9 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
revision: str | int = 'current',
|
||||
automatic_attention_set_update: Optional[bool] = None,
|
||||
step_name: str = None,
|
||||
step_test_data: Callable[[], StepTestData] | None = None) -> None:
|
||||
step_test_data: Callable[[], StepTestData] | None = None,
|
||||
verbose: bool = False,
|
||||
) -> None:
|
||||
"""Add a message to a change at given revision.
|
||||
|
||||
Args:
|
||||
@@ -341,6 +404,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
* step_name: Optional step name.
|
||||
* step_test_data: Optional mock test data for the underlying gerrit
|
||||
client.
|
||||
* verbose: Whether to enable verbose logging.
|
||||
"""
|
||||
args = [
|
||||
'addmessage', '--host', host, '--change',
|
||||
@@ -353,6 +417,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
'--automatic-attention-set-update' if automatic_attention_set_update
|
||||
else '--no-automatic-attention-set-update'
|
||||
]
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
if not step_test_data:
|
||||
step_test_data = lambda: self.m.json.test_api.output({})
|
||||
return self(
|
||||
@@ -366,7 +432,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
project,
|
||||
from_branch,
|
||||
to_branch,
|
||||
step_test_data=None):
|
||||
step_test_data=None,
|
||||
verbose=False):
|
||||
args = [
|
||||
'movechanges', '--host', host, '-p',
|
||||
'project=%s' % project, '-p',
|
||||
@@ -374,6 +441,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
to_branch, '--json_file',
|
||||
self.m.json.output()
|
||||
]
|
||||
if verbose:
|
||||
args.append('--verbose')
|
||||
|
||||
if not step_test_data:
|
||||
step_test_data = lambda: self.test_api.get_one_change_response_data(
|
||||
@@ -396,7 +465,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
submit=False,
|
||||
submit_later=False,
|
||||
step_test_data_create_change=None,
|
||||
step_test_data_submit_change=None):
|
||||
step_test_data_submit_change=None,
|
||||
verbose=False):
|
||||
"""Update a set of files by creating and submitting a Gerrit CL.
|
||||
|
||||
Args:
|
||||
@@ -417,6 +487,8 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
create gerrit change.
|
||||
* step_test_data_submit_change: Optional mock test data for the step
|
||||
submit gerrit change.
|
||||
* verbose: Whether to enable verbose logging.
|
||||
|
||||
|
||||
Returns:
|
||||
A ChangeInfo dictionary as documented here:
|
||||
@@ -426,7 +498,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
"""
|
||||
assert len(new_contents_by_file_path
|
||||
) > 0, 'The dict of file paths should not be empty.'
|
||||
command = [
|
||||
create_command = [
|
||||
'createchange',
|
||||
'--host',
|
||||
host,
|
||||
@@ -440,14 +512,16 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
self.m.json.output(),
|
||||
]
|
||||
for p in params:
|
||||
command.extend(['-p', p])
|
||||
create_command.extend(['-p', p])
|
||||
for cc in cc_list:
|
||||
command.extend(['--cc', cc])
|
||||
create_command.extend(['--cc', cc])
|
||||
if verbose:
|
||||
create_command.append('--verbose')
|
||||
step_test_data = step_test_data_create_change or (
|
||||
lambda: self.test_api.update_files_response_data())
|
||||
|
||||
step_result = self('create change at (%s %s)' % (project, branch),
|
||||
command,
|
||||
create_command,
|
||||
step_test_data=step_test_data)
|
||||
change = int(step_result.json.output.get('_number'))
|
||||
step_result.presentation.links['change %d' %
|
||||
@@ -458,7 +532,7 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
_file = self.m.path.mkstemp()
|
||||
self.m.file.write_raw('store the new content for %s' % path, _file,
|
||||
content)
|
||||
self('edit file %s' % path, [
|
||||
edit_file_command = [
|
||||
'changeedit',
|
||||
'--host',
|
||||
host,
|
||||
@@ -468,15 +542,21 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
path,
|
||||
'--file',
|
||||
_file,
|
||||
])
|
||||
]
|
||||
if verbose:
|
||||
edit_file_command.append('--verbose')
|
||||
self('edit file %s' % path, edit_file_command)
|
||||
|
||||
self('publish edit', [
|
||||
publish_command = [
|
||||
'publishchangeedit',
|
||||
'--host',
|
||||
host,
|
||||
'--change',
|
||||
change,
|
||||
])
|
||||
]
|
||||
if verbose:
|
||||
publish_command.append('--verbose')
|
||||
self('publish edit', publish_command)
|
||||
|
||||
# Make sure the new patchset is propagated to Gerrit backend.
|
||||
with self.m.step.nest('verify the patchset exists on CL %d' % change):
|
||||
@@ -494,15 +574,18 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
self.m.time.sleep((2**retries) * 10)
|
||||
|
||||
if submit or submit_later:
|
||||
self('set Bot-Commit+1 for change %d' % change, [
|
||||
set_bot_commit_command = [
|
||||
'setbotcommit',
|
||||
'--host',
|
||||
host,
|
||||
'--change',
|
||||
change,
|
||||
])
|
||||
]
|
||||
if verbose:
|
||||
set_bot_commit_command.append('--verbose')
|
||||
self('set Bot-Commit+1 for change %d' % change, set_bot_commit_command)
|
||||
if submit:
|
||||
submit_cmd = [
|
||||
submit_command = [
|
||||
'submitchange',
|
||||
'--host',
|
||||
host,
|
||||
@@ -511,9 +594,11 @@ class GerritApi(recipe_api.RecipeApi):
|
||||
'--json_file',
|
||||
self.m.json.output(),
|
||||
]
|
||||
if verbose:
|
||||
submit_command.append('--verbose')
|
||||
step_test_data = step_test_data_submit_change or (
|
||||
lambda: self.test_api.update_files_response_data(status='MERGED'))
|
||||
step_result = self('submit change %d' % change,
|
||||
submit_cmd,
|
||||
submit_command,
|
||||
step_test_data=step_test_data)
|
||||
return step_result.json.output
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"67ebf73496383c6777035e374d2d664009e2aa5c",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json",
|
||||
"--allow-existent-branch"
|
||||
"--allow-existent-branch",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -42,7 +43,8 @@
|
||||
"--branch",
|
||||
"main",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json"
|
||||
"/path/to/tmp/json",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -71,7 +73,8 @@
|
||||
"--commit",
|
||||
"67ebf73496383c6777035e374d2d664009e2aa5c",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json"
|
||||
"/path/to/tmp/json",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -103,7 +106,8 @@
|
||||
"--body",
|
||||
"{\"revision\": \"67ebf73496383c6777035e374d2d664009e2aa5c\"}",
|
||||
"--accept_status",
|
||||
"201"
|
||||
"201",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -135,7 +139,8 @@
|
||||
"--destination_branch",
|
||||
"main",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json"
|
||||
"/path/to/tmp/json",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -185,7 +190,8 @@
|
||||
"-p",
|
||||
"status=NEW",
|
||||
"--cc",
|
||||
"foo@example.com"
|
||||
"foo@example.com",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -249,7 +255,8 @@
|
||||
"--path",
|
||||
"chrome/VERSION",
|
||||
"--file",
|
||||
"[CLEANUP]/tmp_tmp_1"
|
||||
"[CLEANUP]/tmp_tmp_1",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -268,7 +275,8 @@
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--change",
|
||||
"91827"
|
||||
"91827",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -285,7 +293,6 @@
|
||||
"vpython3",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"changes",
|
||||
"--verbose",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--json_file",
|
||||
@@ -297,7 +304,8 @@
|
||||
"-o",
|
||||
"ALL_REVISIONS",
|
||||
"-o",
|
||||
"ALL_COMMITS"
|
||||
"ALL_COMMITS",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -322,7 +330,6 @@
|
||||
"vpython3",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"changes",
|
||||
"--verbose",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--json_file",
|
||||
@@ -334,7 +341,8 @@
|
||||
"-o",
|
||||
"ALL_REVISIONS",
|
||||
"-o",
|
||||
"ALL_COMMITS"
|
||||
"ALL_COMMITS",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -375,7 +383,8 @@
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--change",
|
||||
"91827"
|
||||
"91827",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -393,7 +402,8 @@
|
||||
"--change",
|
||||
"91827",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json"
|
||||
"/path/to/tmp/json",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -428,7 +438,6 @@
|
||||
"vpython3",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"changes",
|
||||
"--verbose",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--json_file",
|
||||
@@ -442,7 +451,8 @@
|
||||
"-p",
|
||||
"status=open",
|
||||
"-p",
|
||||
"label=Commit-Queue>0"
|
||||
"label=Commit-Queue>0",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -486,7 +496,8 @@
|
||||
"--revision",
|
||||
"2",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json"
|
||||
"/path/to/tmp/json",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -529,7 +540,6 @@
|
||||
"vpython3",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"changes",
|
||||
"--verbose",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--json_file",
|
||||
@@ -539,7 +549,8 @@
|
||||
"-p",
|
||||
"status=open",
|
||||
"-p",
|
||||
"label=Commit-Queue>2"
|
||||
"label=Commit-Queue>2",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -556,7 +567,6 @@
|
||||
"vpython3",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"changes",
|
||||
"--verbose",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--json_file",
|
||||
@@ -568,7 +578,8 @@
|
||||
"-o",
|
||||
"ALL_REVISIONS",
|
||||
"-o",
|
||||
"ALL_COMMITS"
|
||||
"ALL_COMMITS",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -613,7 +624,8 @@
|
||||
"/path/to/tmp/json",
|
||||
"-l",
|
||||
"code-review",
|
||||
"-1"
|
||||
"-1",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -639,7 +651,8 @@
|
||||
"/path/to/tmp/json",
|
||||
"-l",
|
||||
"commit-queue",
|
||||
"1"
|
||||
"1",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -667,7 +680,8 @@
|
||||
"This is a non-attention message",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json",
|
||||
"--no-automatic-attention-set-update"
|
||||
"--no-automatic-attention-set-update",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -693,7 +707,8 @@
|
||||
"--message",
|
||||
"This is a comment message",
|
||||
"--json_file",
|
||||
"/path/to/tmp/json"
|
||||
"/path/to/tmp/json",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -717,7 +732,8 @@
|
||||
"--json_file",
|
||||
"/path/to/tmp/json",
|
||||
"--message",
|
||||
"bad roll"
|
||||
"bad roll",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -761,7 +777,8 @@
|
||||
"--json_file",
|
||||
"/path/to/tmp/json",
|
||||
"--message",
|
||||
"nevermind"
|
||||
"nevermind",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
@@ -798,7 +815,6 @@
|
||||
"vpython3",
|
||||
"RECIPE_REPO[depot_tools]/gerrit_client.py",
|
||||
"changes",
|
||||
"--verbose",
|
||||
"--host",
|
||||
"https://chromium-review.googlesource.com",
|
||||
"--json_file",
|
||||
@@ -810,7 +826,8 @@
|
||||
"-o",
|
||||
"ALL_REVISIONS",
|
||||
"-o",
|
||||
"ALL_COMMITS"
|
||||
"ALL_COMMITS",
|
||||
"--verbose"
|
||||
],
|
||||
"env": {
|
||||
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
|
||||
|
||||
@@ -22,13 +22,18 @@ def RunSteps(api):
|
||||
project,
|
||||
branch,
|
||||
commit,
|
||||
allow_existent_branch=True)
|
||||
allow_existent_branch=True,
|
||||
verbose=True)
|
||||
assert data == 'refs/heads/test'
|
||||
|
||||
data = api.gerrit.get_gerrit_branch(host, project, 'main')
|
||||
data = api.gerrit.get_gerrit_branch(host, project, 'main', verbose=True)
|
||||
assert data == '67ebf73496383c6777035e374d2d664009e2aa5c'
|
||||
|
||||
data = api.gerrit.create_gerrit_tag(host, project, '1.0', commit)
|
||||
data = api.gerrit.create_gerrit_tag(host,
|
||||
project,
|
||||
'1.0',
|
||||
commit,
|
||||
verbose=True)
|
||||
assert data == 'refs/tags/1.0'
|
||||
|
||||
tag_body = {
|
||||
@@ -39,10 +44,11 @@ def RunSteps(api):
|
||||
method='PUT',
|
||||
body=tag_body,
|
||||
accept_statuses=[201],
|
||||
name='raw_create_tag')
|
||||
name='raw_create_tag',
|
||||
verbose=True)
|
||||
assert json_data['ref'] == 'refs/tags/1.0'
|
||||
|
||||
api.gerrit.move_changes(host, project, 'master', 'main')
|
||||
api.gerrit.move_changes(host, project, 'master', 'main', verbose=True)
|
||||
|
||||
change_info = api.gerrit.update_files(host,
|
||||
project,
|
||||
@@ -50,7 +56,8 @@ def RunSteps(api):
|
||||
{'chrome/VERSION': '99.99.99.99'},
|
||||
'Dummy CL.',
|
||||
submit=True,
|
||||
cc_list=['foo@example.com'])
|
||||
cc_list=['foo@example.com'],
|
||||
verbose=True)
|
||||
assert int(change_info['_number']) == 91827, change_info
|
||||
assert change_info['status'] == 'MERGED'
|
||||
|
||||
@@ -58,50 +65,54 @@ def RunSteps(api):
|
||||
api.gerrit.get_changes(
|
||||
host,
|
||||
query_params=[
|
||||
('project', 'chromium/src'),
|
||||
('status', 'open'),
|
||||
('label', 'Commit-Queue>0'),
|
||||
('project', 'chromium/src'),
|
||||
('status', 'open'),
|
||||
('label', 'Commit-Queue>0'),
|
||||
],
|
||||
start=1,
|
||||
limit=1,
|
||||
verbose=True,
|
||||
)
|
||||
related_changes = api.gerrit.get_related_changes(host,
|
||||
change='58478',
|
||||
revision='2')
|
||||
revision='2',
|
||||
verbose=True)
|
||||
assert len(related_changes["changes"]) == 1
|
||||
|
||||
# Query which returns no changes is still successful query.
|
||||
empty_list = api.gerrit.get_changes(
|
||||
host,
|
||||
query_params=[
|
||||
('project', 'chromium/src'),
|
||||
('status', 'open'),
|
||||
('label', 'Commit-Queue>2'),
|
||||
('project', 'chromium/src'),
|
||||
('status', 'open'),
|
||||
('label', 'Commit-Queue>2'),
|
||||
],
|
||||
name='changes empty query',
|
||||
verbose=True,
|
||||
)
|
||||
assert len(empty_list) == 0
|
||||
|
||||
api.gerrit.get_change_description(
|
||||
host, change=123, patchset=1)
|
||||
api.gerrit.get_change_description(host, change=123, patchset=1, verbose=True)
|
||||
|
||||
api.gerrit.set_change_label(host, 123, 'code-review', -1)
|
||||
api.gerrit.set_change_label(host, 123, 'commit-queue', 1)
|
||||
api.gerrit.set_change_label(host, 123, 'code-review', -1, verbose=True)
|
||||
api.gerrit.set_change_label(host, 123, 'commit-queue', 1, verbose=True)
|
||||
|
||||
api.gerrit.add_message(host,
|
||||
123,
|
||||
'This is a non-attention message',
|
||||
automatic_attention_set_update=False)
|
||||
api.gerrit.add_message(host, 123, 'This is a comment message')
|
||||
automatic_attention_set_update=False,
|
||||
verbose=True)
|
||||
api.gerrit.add_message(host, 123, 'This is a comment message', verbose=True)
|
||||
|
||||
api.gerrit.abandon_change(host, 123, 'bad roll')
|
||||
api.gerrit.restore_change(host, 123, 'nevermind')
|
||||
api.gerrit.abandon_change(host, 123, 'bad roll', verbose=True)
|
||||
api.gerrit.restore_change(host, 123, 'nevermind', verbose=True)
|
||||
|
||||
api.gerrit.get_change_description(
|
||||
host,
|
||||
change=122,
|
||||
patchset=3,
|
||||
step_test_data=api.gerrit.test_api.get_empty_changes_response_data)
|
||||
step_test_data=api.gerrit.test_api.get_empty_changes_response_data,
|
||||
verbose=True)
|
||||
|
||||
|
||||
def GenTests(api):
|
||||
|
||||
Reference in New Issue
Block a user