Commit ffb5052e authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

delete unused api.gerrit.get_change_destination_branch.

Use api.tryserver.gerrit_change_target_ref instead.
Depends on https://crrev.com/c/1359892

Change-Id: If8ec0bb262035239a1ef77093808196561050c9b
Reviewed-on: https://chromium-review.googlesource.com/c/1359794
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarJao-ke Chin-Lee <jchinlee@chromium.org>
parent 64a001ef
...@@ -332,7 +332,7 @@ Create a new branch from given project and commit ...@@ -332,7 +332,7 @@ Create a new branch from given project and commit
Returns: Returns:
the ref of the branch created the ref of the branch created
&mdash; **def [get\_change\_description](/recipes/recipe_modules/gerrit/api.py#106)(self, host, change, patchset):** &mdash; **def [get\_change\_description](/recipes/recipe_modules/gerrit/api.py#72)(self, host, change, patchset):**
Get the description for a given CL and patchset. Get the description for a given CL and patchset.
...@@ -344,20 +344,7 @@ Args: ...@@ -344,20 +344,7 @@ Args:
Returns: Returns:
The description corresponding to given CL and patchset. The description corresponding to given CL and patchset.
&mdash; **def [get\_change\_destination\_branch](/recipes/recipe_modules/gerrit/api.py#72)(self, host, change, name=None, step_test_data=None):** &mdash; **def [get\_changes](/recipes/recipe_modules/gerrit/api.py#117)(self, host, query_params, start=None, limit=None, o_params=None, step_test_data=None, \*\*kwargs):**
Get the upstream branch for a given CL.
Result is cached.
Args:
host: URL of Gerrit host to query.
change: The change number.
Returns:
the name of the branch
&mdash; **def [get\_changes](/recipes/recipe_modules/gerrit/api.py#151)(self, host, query_params, start=None, limit=None, o_params=None, step_test_data=None, \*\*kwargs):**
Query changes for the given host. Query changes for the given host.
...@@ -382,7 +369,7 @@ Get a branch from given project and commit ...@@ -382,7 +369,7 @@ Get a branch from given project and commit
Returns: Returns:
the revision of the branch the revision of the branch
&mdash; **def [get\_revision\_info](/recipes/recipe_modules/gerrit/api.py#121)(self, host, change, patchset):** &mdash; **def [get\_revision\_info](/recipes/recipe_modules/gerrit/api.py#87)(self, host, change, patchset):**
Returns the info for a given patchset of a given change. Returns the info for a given patchset of a given change.
......
...@@ -69,40 +69,6 @@ class GerritApi(recipe_api.RecipeApi): ...@@ -69,40 +69,6 @@ class GerritApi(recipe_api.RecipeApi):
revision = step_result.json.output.get('revision') revision = step_result.json.output.get('revision')
return revision return revision
def get_change_destination_branch(
self, host, change, name=None, step_test_data=None):
"""
Get the upstream branch for a given CL.
Result is cached.
Args:
host: URL of Gerrit host to query.
change: The change number.
Returns:
the name of the branch
"""
assert int(change), change
change = int(change)
branch = self._changes_target_branch_cache.get((host, change))
if branch is not None:
return branch
changes = self.get_changes(
host,
[('change', change)],
limit=1,
name=name or 'get_change_destination_branch',
step_test_data=step_test_data,
)
if not changes or 'branch' not in changes[0]:
self.m.step.active_result.presentation.status = self.m.step.EXCEPTION
raise self.m.step.InfraFailure(
'Error quering for branch of CL %s' % change)
branch = changes[0]['branch']
self._changes_target_branch_cache[(host, change)] = branch
return branch
def get_change_description(self, host, change, patchset): def get_change_description(self, host, change, patchset):
""" """
Get the description for a given CL and patchset. Get the description for a given CL and patchset.
......
...@@ -118,41 +118,20 @@ ...@@ -118,41 +118,20 @@
"https://chromium-review.googlesource.com", "https://chromium-review.googlesource.com",
"--json_file", "--json_file",
"/path/to/tmp/json", "/path/to/tmp/json",
"--limit",
"1",
"-p", "-p",
"change=123", "project=chromium/src",
"-o", "-p",
"ALL_REVISIONS", "status=open",
"-o", "-p",
"ALL_COMMITS" "label=Commit-Queue>2"
], ],
"env": { "env": {
"PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]" "PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]"
}, },
"infra_step": true, "infra_step": true,
"name": "gerrit changes (2)", "name": "gerrit changes empty query",
"~followup_annotations": [ "~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@", "@@@STEP_LOG_LINE@json.output@[]@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
"@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"branch\": \"master\", @@@",
"@@@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\": \"NEW\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"subject\": \"Change title\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@]@@@",
"@@@STEP_LOG_END@json.output@@@" "@@@STEP_LOG_END@json.output@@@"
] ]
}, },
...@@ -169,13 +148,17 @@ ...@@ -169,13 +148,17 @@
"--limit", "--limit",
"1", "1",
"-p", "-p",
"change=123" "change=123",
"-o",
"ALL_REVISIONS",
"-o",
"ALL_COMMITS"
], ],
"env": { "env": {
"PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]" "PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]"
}, },
"infra_step": true, "infra_step": true,
"name": "gerrit get_change_destination_branch", "name": "gerrit changes (2)",
"~followup_annotations": [ "~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@", "@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@", "@@@STEP_LOG_LINE@json.output@ {@@@",
...@@ -200,32 +183,6 @@ ...@@ -200,32 +183,6 @@
"@@@STEP_LOG_END@json.output@@@" "@@@STEP_LOG_END@json.output@@@"
] ]
}, },
{
"cmd": [
"python",
"-u",
"RECIPE_PACKAGE_REPO[depot_tools]/gerrit_client.py",
"changes",
"--host",
"https://chromium-review.googlesource.com",
"--json_file",
"/path/to/tmp/json",
"--limit",
"1",
"-p",
"change=122"
],
"env": {
"PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
"name": "gerrit missing_cl",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[]@@@",
"@@@STEP_LOG_END@json.output@@@",
"@@@STEP_EXCEPTION@@@"
]
},
{ {
"cmd": [ "cmd": [
"python", "python",
...@@ -279,7 +236,7 @@ ...@@ -279,7 +236,7 @@
"failure": { "failure": {
"step": "Aggregate step failure." "step": "Aggregate step failure."
}, },
"humanReason": "2 out of 2 aggregated steps failed. Failures: Error quering for branch of CL 122, Error querying for CL description: host:'https://chromium-review.googlesource.com' change:122; patchset:3" "humanReason": "1 out of 1 aggregated steps failed. Failures: Error querying for CL description: host:'https://chromium-review.googlesource.com' change:122; patchset:3"
}, },
"name": "$result" "name": "$result"
} }
......
...@@ -33,18 +33,22 @@ def RunSteps(api): ...@@ -33,18 +33,22 @@ def RunSteps(api):
limit=1, limit=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'),
],
name='changes empty query',
)
assert len(empty_list) == 0
api.gerrit.get_change_description( api.gerrit.get_change_description(
host, change=123, patchset=1) host, change=123, patchset=1)
first = api.gerrit.get_change_destination_branch(host, change=123)
# Second call returns cached data.
second = api.gerrit.get_change_destination_branch(host, change=123)
assert first == second
with api.step.defer_results(): with api.step.defer_results():
api.gerrit.get_change_destination_branch(
host, change=122, name='missing_cl')
api.gerrit.get_change_description( api.gerrit.get_change_description(
host, change=122, patchset=3) host, change=122, patchset=3)
...@@ -61,7 +65,7 @@ def GenTests(api): ...@@ -61,7 +65,7 @@ def GenTests(api):
api.gerrit.make_gerrit_get_branch_response_data() api.gerrit.make_gerrit_get_branch_response_data()
) )
+ api.step_data( + api.step_data(
'gerrit missing_cl', 'gerrit changes empty query',
api.gerrit.get_empty_changes_response_data() api.gerrit.get_empty_changes_response_data()
) )
) )
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