diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md
index 9c893b5ad5..ce40665248 100644
--- a/recipes/README.recipes.md
+++ b/recipes/README.recipes.md
@@ -46,18 +46,18 @@
Recipe module to ensure a checkout is consistent on a bot.
-#### **class [BotUpdateApi](/recipes/recipe_modules/bot_update/api.py#12)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
+#### **class [BotUpdateApi](/recipes/recipe_modules/bot_update/api.py#13)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
-— **def [\_\_call\_\_](/recipes/recipe_modules/bot_update/api.py#43)(self, name, cmd, \*\*kwargs):**
+— **def [\_\_call\_\_](/recipes/recipe_modules/bot_update/api.py#61)(self, name, cmd, \*\*kwargs):**
Wrapper for easy calling of bot_update.
-— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#393)(self, bot_update_step):**
+— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#367)(self, bot_update_step):**
Deapplies a patch, taking care of DEPS and solution revisions properly.
-— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#56)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, refs=None, patch_oauth2=None, oauth2_json=None, use_site_config_creds=None, clobber=False, root_solution_revision=None, rietveld=None, issue=None, patchset=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, disable_syntax_validation=False, manifest_name=None, patch_refs=None, \*\*kwargs):**
+— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#74)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, refs=None, patch_oauth2=None, oauth2_json=None, use_site_config_creds=None, clobber=False, root_solution_revision=None, rietveld=None, issue=None, patchset=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, disable_syntax_validation=False, manifest_name=None, patch_refs=None, \*\*kwargs):**
Args:
gclient_config: The gclient configuration to use when running bot_update.
@@ -68,7 +68,7 @@ Args:
manifest_name: The name of the manifest to upload to LogDog. This must
be unique for the whole build.
-— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#370)(self, project_name, gclient_config=None):**
+— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#344)(self, project_name, gclient_config=None):**
Returns all property names used for storing the checked-out revision of
a given project.
@@ -82,9 +82,9 @@ Args:
Returns (list of str): All properties that'll hold the checked-out revision
of the given project. An empty list if no such properties exist.
-— **def [initialize](/recipes/recipe_modules/bot_update/api.py#33)(self):**
+— **def [initialize](/recipes/recipe_modules/bot_update/api.py#51)(self):**
- **@property**
— **def [last\_returned\_properties](/recipes/recipe_modules/bot_update/api.py#52)(self):**
+ **@property**
— **def [last\_returned\_properties](/recipes/recipe_modules/bot_update/api.py#70)(self):**
### *recipe_modules* / [cipd](/recipes/recipe_modules/cipd)
[DEPS](/recipes/recipe_modules/cipd/__init__.py#1): [infra\_paths](#recipe_modules-infra_paths), [recipe\_engine/json][recipe_engine/recipe_modules/json], [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/step][recipe_engine/recipe_modules/step]
@@ -337,6 +337,8 @@ Create a new branch from given project and commit
Returns:
the ref of the branch created
+— **def [extract\_patchset\_info](/recipes/recipe_modules/gerrit/api.py#148)(self, change_info, patchset):**
+
— **def [get\_change\_description](/recipes/recipe_modules/gerrit/api.py#106)(self, host, change, patchset):**
Get the description for a given CL and patchset.
@@ -362,7 +364,7 @@ Args:
Returns:
the name of the branch
-— **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):**
+— **def [get\_changes](/recipes/recipe_modules/gerrit/api.py#158)(self, host, query_params, start=None, limit=None, o_params=None, step_test_data=None, \*\*kwargs):**
Query changes for the given host.
diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py
index 2622ca4fa6..813076e443 100644
--- a/recipes/recipe_modules/bot_update/api.py
+++ b/recipes/recipe_modules/bot_update/api.py
@@ -5,6 +5,7 @@
"""Recipe module to ensure a checkout is consistent on a bot."""
import re
+import urllib
from recipe_engine import recipe_api
@@ -17,7 +18,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
deps_revision_overrides, fail_patch, *args, **kwargs):
self._apply_patch_on_gclient = properties.get(
'apply_patch_on_gclient', True)
- self._issue = patch_issue
+ self._change = patch_issue
self._patchset = patch_set
self._repository = repository or patch_repository_url
self._gerrit_ref = patch_ref
@@ -27,6 +28,23 @@ class BotUpdateApi(recipe_api.RecipeApi):
self._deps_revision_overrides = deps_revision_overrides
self._fail_patch = fail_patch
+ # A map of change => target branch for change in Gerrit.
+ # We need the target-branch that the change was uploaded against. We use
+ # it to find a merge base between the change-ref and the target-branch, so
+ # we can find what commits constitute the change:
+ #
+ # Graphically, it looks like this:
+ #
+ # ... -> merge-base -> [possibly already landed commits] -> target-branch
+ # |
+ # -------> [possibly not yet landed dependent CLs] -> change-ref
+ self._target_branch_for_change = {}
+
+ # A map of change => path where the change should be applied to. Needed to
+ # tell gclient to sync the path to the target-branch for the patch instead
+ # of 'master'.
+ self._change_for_path = {}
+
self._last_returned_properties = {}
super(BotUpdateApi, self).__init__(*args, **kwargs)
@@ -118,15 +136,8 @@ class BotUpdateApi(recipe_api.RecipeApi):
['--output_json', self.m.json.output()],
]
- # How to find the patch, if any
if patch:
- if self._repository and self._gerrit_ref:
- flags.append(
- ['--patch_ref', '%s@%s' % (self._repository, self._gerrit_ref)])
- if patch_refs:
- flags.extend(
- ['--patch_ref', patch_ref]
- for patch_ref in patch_refs)
+ flags += self._get_info_for_changes(cfg, patch_refs or [])
# Compute requested revisions.
revisions = {}
@@ -159,9 +170,10 @@ class BotUpdateApi(recipe_api.RecipeApi):
fixed_revision = self.m.gclient.resolve_revision(revision)
if fixed_revision:
fixed_revisions[name] = fixed_revision
- if fixed_revision.upper() == 'HEAD':
+ if fixed_revision.upper() == 'HEAD' and name in self._change_for_path:
# Sync to correct destination branch if HEAD was specified.
- fixed_revision = self._destination_branch(cfg, name)
+ branch = self._target_branch_for_change[self._change_for_path[name]]
+ fixed_revision = branch if branch != 'master' else 'HEAD'
# If we're syncing to a ref, we want to make sure it exists before
# trying to check it out.
if (fixed_revision.startswith('refs/') and
@@ -289,44 +301,6 @@ class BotUpdateApi(recipe_api.RecipeApi):
return step_result
- def _destination_branch(self, cfg, path):
- """Returns the destination branch of a CL for the matching project
- if available or HEAD otherwise.
-
- This is a noop if there's no Gerrit CL associated with the run.
- Otherwise this queries Gerrit for the correct destination branch, which
- might differ from master.
-
- Args:
- cfg: The used gclient config.
- path: The DEPS path of the project this prefix is for. E.g. 'src' or
- 'src/v8'. The query will only be made for the project that matches
- the CL's project.
- Returns:
- A destination branch as understood by bot_update.py if available
- and if different from master, returns 'HEAD' otherwise.
- """
- # Bail out if this is not a gerrit issue.
- if (not self.m.tryserver.is_gerrit_issue or
- not self._gerrit or not self._issue):
- return 'HEAD'
-
- # Ignore other project paths than the one belonging to the CL.
- if path != cfg.patch_projects.get(
- self.m.properties.get('patch_project'),
- (cfg.solutions[0].name, None))[0]:
- return 'HEAD'
-
- # Query Gerrit to check if a CL's destination branch differs from master.
- destination_branch = self.m.gerrit.get_change_destination_branch(
- host=self._gerrit,
- change=self._issue,
- name='get_patch_destination_branch',
- )
-
- # Only use prefix if different from bot_update.py's default.
- return destination_branch if destination_branch != 'master' else 'HEAD'
-
def _resolve_fixed_revisions(self, bot_update_json):
"""Set all fixed revisions from the first sync to their respective
got_X_revision values.
@@ -406,3 +380,95 @@ class BotUpdateApi(recipe_api.RecipeApi):
self._resolve_fixed_revisions(bot_update_json)
self.ensure_checkout(patch=False, update_presentation=False)
+
+ def _get_info_for_changes(self, cfg, changes):
+ """Get the project, target branch and ref for the given changes.
+
+ Also populates the _target_branch_for_change and _change_for_path mappings.
+
+ Args:
+ cfg: The gclient configuration to use.
+ changes: A list of dicts dict with 'host', 'number', 'patchset' and
+ optionally 'project' to process.
+ e.g. [{'host': 'https://chromium-review.googlesource.com',
+ 'number': 12345,
+ 'patchset': 3,
+ 'project': 'v8/v8'}]
+ TODO(ehmaldonado): Remove once all callers use dicts instead of
+ strings.
+ We temporarily support passing a '@' change ref, but
+ we don't get any branch information, so the changes are assumed to
+ have been uploaded against the master branch.
+
+ Returns:
+ A list of flags to pass to bot_update.py specifying the patch_refs to pass
+ in the format '--patch-ref @:'.
+ """
+ changes = list(changes)
+ if self._gerrit and self._patchset:
+ changes.append({
+ 'host': self._gerrit,
+ 'number': self._change,
+ 'patchset': self._patchset,
+ 'project': self.m.properties.get('patch_project'),
+ })
+
+ change_ref_flags = []
+ self._target_branch_for_change = {}
+ self._change_for_path = {}
+ for change in changes:
+ # TODO(ehmaldonado): Remove once all callers use dicts instead of
+ # strings.
+ # Temporarily support passing the patch_refs directly.
+ if isinstance(change, str):
+ change_ref_flags.append(['--patch_ref', change])
+ continue
+
+ # If project is known, specify it so that Gerrit queries are faster.
+ change_id = change['number']
+ if change.get('project'):
+ change_id = '{}~{}'.format(
+ urllib.quote(change['project'], safe=''),
+ change['number'])
+
+ step_test_data = self.m.gerrit.test_api.get_one_change_response_data(
+ change=change['number'],
+ patchset=change['patchset'],
+ project=change.get('project'),
+ o_params=['ALL_REVISIONS', 'DOWNLOAD_COMMANDS'])
+
+ change_info = self.m.gerrit.get_changes(
+ host=change['host'],
+ query_params=[('change', change_id)],
+ o_params=['ALL_REVISIONS', 'DOWNLOAD_COMMANDS'],
+ limit=1,
+ name=('get change info for '
+ '{host}/c/{number}/{patchset}'.format(**change)),
+ step_test_data=lambda: step_test_data)[0]
+
+ # Get the path for the change project. Default to the first solution if
+ # not found.
+ patch_path = cfg.patch_projects.get(
+ change_info['project'], [cfg.solutions[0].name])[0]
+
+ change_key = (change['host'], change['number'])
+
+ # Make sure no two CLs refer to the same path.
+ assert patch_path not in self._change_for_path, (
+ 'Issues {} and {} refer to the same path: {}'.format(
+ self._change_for_path[patch_path], change_key, patch_path))
+
+ self._target_branch_for_change[change_key] = change_info['branch']
+ self._change_for_path[patch_path] = change_key
+
+ patchset_info = self.m.gerrit.extract_patchset_info(
+ change_info, change['patchset'])['fetch']['http']
+ change_ref_flags.append([
+ '--patch_ref',
+ '{}@{}:{}'.format(
+ patchset_info['url'],
+ change_info['branch'],
+ patchset_info['ref'])
+ ])
+
+ return change_ref_flags
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json b/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json
index 634268440a..984128efb8 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json
@@ -1,4 +1,58 @@
[
+ {
+ "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=1234",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
+ ],
+ "env": {
+ "PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
+ },
+ "infra_step": true,
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/1234/5",
+ "~followup_annotations": [
+ "@@@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\": 5, @@@",
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/5\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/chromium/src\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
+ "@@@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@@@"
+ ]
+ },
{
"cmd": [
"python",
@@ -17,9 +71,9 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/chromium/src@refs/changes/12/34/5",
+ "https://chromium.googlesource.com/chromium/src@master:refs/changes/27/91827/5",
"--patch_ref",
- "https://chromium.googlesource.com/v8/v8@refs/changes/124/45/6",
+ "https://webrtc.googlesource.com/src@refs/changes/78/5678/6",
"--revision",
"src@HEAD",
"--disable-syntax-validation"
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json b/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json
index 02056cd01c..66725a0729 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json
@@ -12,27 +12,37 @@
"--limit",
"1",
"-p",
- "change=338811"
+ "change=angle%2Fangle~91827",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/91827/1",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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@ \"project\": \"angle/angle\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"1\", @@@",
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/angle/angle\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/angle/angle@refs/changes/11/338811/3",
+ "https://chromium.googlesource.com/angle/angle@master:refs/changes/27/91827/1",
"--revision",
"src@HEAD",
"--revision",
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json
index b060d5e6df..557aa069a2 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json
@@ -12,27 +12,37 @@
"--limit",
"1",
"-p",
- "change=338811"
+ "change=angle%2Fangle~91827",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/91827/1",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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@ \"project\": \"angle/angle\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"1\", @@@",
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/angle/angle\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/angle/angle@refs/changes/11/338811/3",
+ "https://chromium.googlesource.com/angle/angle@master:refs/changes/27/91827/1",
"--revision",
"src@HEAD",
"--revision",
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json
index a7907f6831..ca69689935 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json
@@ -12,17 +12,21 @@
"--limit",
"1",
"-p",
- "change=338811"
+ "change=chromium%2Fsrc~91827",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/91827/1",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"_number\": 91827, @@@",
"@@@STEP_LOG_LINE@json.output@ \"branch\": \"refs/branch-heads/67\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
@@ -30,9 +34,15 @@
"@@@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@ \"_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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/chromium/src\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/chromium/src@refs/changes/11/338811/3",
+ "https://chromium.googlesource.com/chromium/src@refs/branch-heads/67:refs/changes/27/91827/1",
"--revision",
"src@refs/branch-heads/67",
"--refs",
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json
index cc8fd07a11..e49567cd3a 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json
@@ -12,17 +12,21 @@
"--limit",
"1",
"-p",
- "change=338811"
+ "change=chromium%2Fsrc~91827",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/91827/1",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"_number\": 91827, @@@",
"@@@STEP_LOG_LINE@json.output@ \"branch\": \"experimental/feature\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"change_id\": \"Ideadbeef\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"created\": \"2017-01-30 13:11:20.000000000\", @@@",
@@ -30,9 +34,15 @@
"@@@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@ \"_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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/chromium/src\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/chromium/src@refs/changes/11/338811/3",
+ "https://chromium.googlesource.com/chromium/src@experimental/feature:refs/changes/27/91827/1",
"--revision",
"src@experimental/feature",
"--disable-syntax-validation"
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json
index 69dac547ab..56b62a8b4c 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json
@@ -12,27 +12,37 @@
"--limit",
"1",
"-p",
- "change=338811"
+ "change=v8%2Fv8~91827",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/91827/1",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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@ \"project\": \"v8/v8\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"1\", @@@",
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/v8/v8\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/v8/v8@refs/changes/11/338811/3",
+ "https://chromium.googlesource.com/v8/v8@master:refs/changes/27/91827/1",
"--revision",
"src@HEAD",
"--revision",
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json
index 6b76ed12c7..202eea4ca0 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json
@@ -12,27 +12,37 @@
"--limit",
"1",
"-p",
- "change=338811"
+ "change=v8%2Fv8~91827",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/91827/1",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"_number\": 91827, @@@",
"@@@STEP_LOG_LINE@json.output@ \"branch\": \"experimental/feature\", @@@",
"@@@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@ \"project\": \"v8/v8\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"1\", @@@",
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/v8/v8\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/v8/v8@refs/changes/11/338811/3",
+ "https://chromium.googlesource.com/v8/v8@experimental/feature:refs/changes/27/91827/1",
"--revision",
"src@HEAD",
"--revision",
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json
index 714458fb7d..164b0555e5 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json
@@ -12,27 +12,37 @@
"--limit",
"1",
"-p",
- "change=338811"
+ "change=src~91827",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://webrtc-review.googlesource.com/c/91827/1",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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@ \"project\": \"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@ \"_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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://webrtc.googlesource.com/src\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://webrtc.googlesource.com/src@refs/changes/11/338811/3",
+ "https://webrtc.googlesource.com/src@master:refs/changes/27/91827/1",
"--revision",
"src@HEAD",
"--disable-syntax-validation"
diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json
index 95ea1d3963..6c63cfba39 100644
--- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json
+++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json
@@ -12,27 +12,37 @@
"--limit",
"1",
"-p",
- "change=456789"
+ "change=v8%2Fv8~456789",
+ "-o",
+ "ALL_REVISIONS",
+ "-o",
+ "DOWNLOAD_COMMANDS"
],
"env": {
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit get_patch_destination_branch",
+ "name": "gerrit get change info for https://chromium-review.googlesource.com/c/456789/12",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"_number\": 456789, @@@",
"@@@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@ \"project\": \"v8/v8\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"_number\": 12, @@@",
"@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/89/456789/12\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/v8/v8\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
@@ -61,7 +71,7 @@
"--output_json",
"/path/to/tmp/json",
"--patch_ref",
- "https://chromium.googlesource.com/chromium/src@refs/changes/89/456789/12",
+ "https://chromium.googlesource.com/v8/v8@master:refs/changes/89/456789/12",
"--revision",
"src@HEAD",
"--revision",
diff --git a/recipes/recipe_modules/bot_update/examples/full.py b/recipes/recipe_modules/bot_update/examples/full.py
index 536206118b..1102bde6df 100644
--- a/recipes/recipe_modules/bot_update/examples/full.py
+++ b/recipes/recipe_modules/bot_update/examples/full.py
@@ -37,6 +37,7 @@ def RunSteps(api):
'HEAD')
api.gclient.c.repo_path_map['https://webrtc.googlesource.com/src'] = (
'src/third_party/webrtc', 'HEAD')
+ api.gclient.c.patch_projects['webrtc'] = ('src/third_party/webrtc', 'HEAD')
patch = api.properties.get('patch', True)
clobber = True if api.properties.get('clobber') else False
@@ -147,64 +148,94 @@ def GenTests(api):
issue=12345,
patchset=654321,
rietveld='https://rietveld.example.com/',
- patch_project='v8',
+ patch_project='v8/v8',
revisions={'src/v8': 'abc'}
)
yield api.test('tryjob_v8_head_by_default') + api.properties.tryserver(
- patch_project='v8',
+ patch_project='v8/v8',
)
yield api.test('tryjob_gerrit_angle') + api.properties.tryserver(
- gerrit_project='angle/angle',
- patch_issue=338811,
- patch_set=3,
+ patch_project='angle/angle',
+ patch_issue=91827,
+ patch_set=1,
)
yield api.test('no_apply_patch_on_gclient') + api.properties.tryserver(
- gerrit_project='angle/angle',
- patch_issue=338811,
- patch_set=3,
+ patch_project='angle/angle',
+ patch_issue=91827,
+ patch_set=1,
) + api.bot_update.properties(
apply_patch_on_gclient=False,
)
yield api.test('tryjob_gerrit_v8') + api.properties.tryserver(
- gerrit_project='v8/v8',
- patch_issue=338811,
- patch_set=3,
+ patch_project='v8/v8',
+ patch_issue=91827,
+ patch_set=1,
)
yield api.test('tryjob_gerrit_v8_feature_branch') + api.properties.tryserver(
- gerrit_project='v8/v8',
- patch_issue=338811,
- patch_set=3,
+ patch_project='v8/v8',
+ patch_issue=91827,
+ patch_set=1,
) + api.step_data(
- 'gerrit get_patch_destination_branch',
- api.gerrit.get_one_change_response_data(branch='experimental/feature'),
+ 'gerrit get change info for '
+ 'https://chromium-review.googlesource.com/c/91827/1',
+ api.gerrit.get_one_change_response_data(
+ branch='experimental/feature',
+ project='v8/v8',
+ o_params=['DOWNLOAD_COMMANDS'],
+ ),
)
yield api.test('tryjob_gerrit_feature_branch') + api.properties.tryserver(
buildername='feature_rel',
- gerrit_project='chromium/src',
- patch_issue=338811,
- patch_set=3,
+ patch_project='chromium/src',
+ patch_issue=91827,
+ patch_set=1,
) + api.step_data(
- 'gerrit get_patch_destination_branch',
- api.gerrit.get_one_change_response_data(branch='experimental/feature'),
+ 'gerrit get change info for '
+ 'https://chromium-review.googlesource.com/c/91827/1',
+ api.gerrit.get_one_change_response_data(
+ branch='experimental/feature',
+ o_params=['DOWNLOAD_COMMANDS'],
+ ),
)
yield api.test('tryjob_gerrit_branch_heads') + api.properties.tryserver(
- gerrit_project='chromium/src',
- patch_issue=338811,
- patch_set=3,
+ patch_project='chromium/src',
+ patch_issue=91827,
+ patch_set=1,
) + api.step_data(
- 'gerrit get_patch_destination_branch',
- api.gerrit.get_one_change_response_data(branch='refs/branch-heads/67'),
+ 'gerrit get change info for '
+ 'https://chromium-review.googlesource.com/c/91827/1',
+ api.gerrit.get_one_change_response_data(
+ branch='refs/branch-heads/67',
+ o_params=['DOWNLOAD_COMMANDS'],
+ ),
)
yield api.test('tryjob_gerrit_webrtc') + api.properties.tryserver(
- gerrit_project='src',
+ patch_project='src',
git_url='https://webrtc.googlesource.com/src',
- patch_issue=338811,
- patch_set=3,
+ patch_issue=91827,
+ patch_set=1,
+ ) + api.step_data(
+ 'gerrit get change info for '
+ 'https://webrtc-review.googlesource.com/c/91827/1',
+ api.gerrit.get_one_change_response_data(
+ project='src',
+ host='https://webrtc.googlesource.com/src',
+ o_params=['DOWNLOAD_COMMANDS'],
+ ),
)
yield api.test('multiple_patch_refs') + api.properties(
patch=True,
patch_refs=[
- 'https://chromium.googlesource.com/chromium/src@refs/changes/12/34/5',
- 'https://chromium.googlesource.com/v8/v8@refs/changes/124/45/6',
+ {'host': 'https://chromium-review.googlesource.com',
+ 'number': 1234,
+ 'patchset': 5},
+ 'https://webrtc.googlesource.com/src@refs/changes/78/5678/6',
],
+ ) + api.step_data(
+ 'gerrit get change info for '
+ 'https://chromium-review.googlesource.com/c/1234/5',
+ api.gerrit.get_one_change_response_data(
+ patchset=5,
+ o_params=['DOWNLOAD_COMMANDS'],
+ ),
)
diff --git a/recipes/recipe_modules/gerrit/api.py b/recipes/recipe_modules/gerrit/api.py
index 939b370764..3099b5df5f 100644
--- a/recipes/recipe_modules/gerrit/api.py
+++ b/recipes/recipe_modules/gerrit/api.py
@@ -138,15 +138,22 @@ class GerritApi(recipe_api.RecipeApi):
query_params=[('change', str(change))],
o_params=['ALL_REVISIONS', 'ALL_COMMITS'],
limit=1)
- cl = cls[0] if len(cls) == 1 else {'revisions': {}}
- for ri in cl['revisions'].itervalues():
+
+ if len(cls) != 1: # pragma: no cover
+ raise self.m.step.InfraFailure(
+ 'Change not found: host:%r change:%r' % (host, change))
+
+ return self.extract_patchset_info(cls[0], patchset)
+
+ def extract_patchset_info(self, change_info, patchset):
+ for revision in change_info['revisions'].itervalues():
# TODO(tandrii): add support for patchset=='current'.
- if str(ri['_number']) == str(patchset):
- return ri
+ if str(revision['_number']) == str(patchset):
+ return revision
raise self.m.step.InfraFailure(
- 'Error querying for CL description: host:%r change:%r; patchset:%r' % (
- host, change, patchset))
+ 'Patchset %r not found for change %r' % (
+ patchset, change_info['_number']))
def get_changes(self, host, query_params, start=None, limit=None,
o_params=None, step_test_data=None, **kwargs):
diff --git a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json
index 251783ba0e..964d81cb14 100644
--- a/recipes/recipe_modules/gerrit/examples/full.expected/basic.json
+++ b/recipes/recipe_modules/gerrit/examples/full.expected/basic.json
@@ -87,7 +87,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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\", @@@",
@@ -95,7 +95,7 @@
"@@@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@ \"_number\": 1, @@@",
"@@@STEP_LOG_LINE@json.output@ \"commit\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"message\": \"Change commit message\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
@@ -108,6 +108,184 @@
"@@@STEP_LOG_END@json.output@@@"
]
},
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "RECIPE_PACKAGE_REPO[depot_tools]/gerrit_client.py",
+ "changes",
+ "--host",
+ "fake_host",
+ "--json_file",
+ "/path/to/tmp/json"
+ ],
+ "env": {
+ "PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
+ },
+ "infra_step": true,
+ "name": "gerrit changes (2)",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@json.output@[@@@",
+ "@@@STEP_LOG_LINE@json.output@ {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"_number\": 91827, @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"branch\": \"feature\", @@@",
+ "@@@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@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "RECIPE_PACKAGE_REPO[depot_tools]/gerrit_client.py",
+ "changes",
+ "--host",
+ "fake_host",
+ "--json_file",
+ "/path/to/tmp/json"
+ ],
+ "env": {
+ "PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
+ },
+ "infra_step": true,
+ "name": "gerrit changes (3)",
+ "~followup_annotations": [
+ "@@@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\": \"foo/bar\", @@@",
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/foo/bar\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
+ "@@@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@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "RECIPE_PACKAGE_REPO[depot_tools]/gerrit_client.py",
+ "changes",
+ "--host",
+ "fake_host",
+ "--json_file",
+ "/path/to/tmp/json"
+ ],
+ "env": {
+ "PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
+ },
+ "infra_step": true,
+ "name": "gerrit changes (4)",
+ "~followup_annotations": [
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/27/91827/1\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://foo.googlesource.com/bar\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
+ "@@@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@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "RECIPE_PACKAGE_REPO[depot_tools]/gerrit_client.py",
+ "changes",
+ "--host",
+ "fake_host",
+ "--json_file",
+ "/path/to/tmp/json"
+ ],
+ "env": {
+ "PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
+ },
+ "infra_step": true,
+ "name": "gerrit changes (5)",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@json.output@[@@@",
+ "@@@STEP_LOG_LINE@json.output@ {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"_number\": 1234, @@@",
+ "@@@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\": 5, @@@",
+ "@@@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@ \"fetch\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"http\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"ref\": \"refs/changes/34/1234/5\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"url\": \"https://chromium.googlesource.com/chromium/src\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
+ "@@@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@@@"
+ ]
+ },
{
"cmd": [
"python",
@@ -131,11 +309,11 @@
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit changes (2)",
+ "name": "gerrit changes (6)",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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\", @@@",
@@ -143,7 +321,7 @@
"@@@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@ \"_number\": 1, @@@",
"@@@STEP_LOG_LINE@json.output@ \"commit\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"message\": \"Change commit message\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
@@ -179,7 +357,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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\", @@@",
@@ -187,7 +365,7 @@
"@@@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@ \"_number\": 1, @@@",
"@@@STEP_LOG_LINE@json.output@ \"commit\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"message\": \"Change commit message\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
@@ -249,11 +427,11 @@
"PATH": ":RECIPE_PACKAGE_REPO[depot_tools]"
},
"infra_step": true,
- "name": "gerrit changes (3)",
+ "name": "gerrit changes (7)",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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\", @@@",
@@ -261,7 +439,7 @@
"@@@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@ \"_number\": 1, @@@",
"@@@STEP_LOG_LINE@json.output@ \"commit\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"message\": \"Change commit message\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
@@ -276,7 +454,7 @@
},
{
"name": "$result",
- "reason": "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",
+ "reason": "2 out of 2 aggregated steps failed. Failures: Error quering for branch of CL 122, Patchset 3 not found for change 91827",
"recipe_result": null,
"status_code": 1
}
diff --git a/recipes/recipe_modules/gerrit/examples/full.py b/recipes/recipe_modules/gerrit/examples/full.py
index 09dbf2f0cd..f28714ed5c 100644
--- a/recipes/recipe_modules/gerrit/examples/full.py
+++ b/recipes/recipe_modules/gerrit/examples/full.py
@@ -22,7 +22,7 @@ def RunSteps(api):
assert data == '67ebf73496383c6777035e374d2d664009e2aa5c'
# Query for changes in Chromium's CQ.
- api.gerrit.get_changes(
+ change = api.gerrit.get_changes(
host,
query_params=[
('project', 'chromium/src'),
@@ -33,6 +33,28 @@ def RunSteps(api):
limit=1,
)
+ # Test get_one_change_response_data
+ def get_change(**kwargs):
+ test = lambda: api.gerrit.test_api.get_one_change_response_data(**kwargs)
+ return api.gerrit.get_changes('fake_host', [], step_test_data=test)[0]
+
+ change = get_change(branch='feature')
+ assert change['branch'] == 'feature'
+
+ change = get_change(o_params=['DOWNLOAD_COMMANDS'], project='foo/bar')
+ assert change['project'] == 'foo/bar'
+ assert change['revisions'].values()[0]['fetch']['http']['url'] == (
+ 'https://chromium.googlesource.com/foo/bar')
+
+ change = get_change(o_params=['DOWNLOAD_COMMANDS'],
+ host='https://foo.googlesource.com/bar')
+ assert change['revisions'].values()[0]['fetch']['http']['url'] == (
+ 'https://foo.googlesource.com/bar')
+
+ change = get_change(o_params=['DOWNLOAD_COMMANDS'], change=1234, patchset=5)
+ assert change['revisions'].values()[0]['fetch']['http']['ref'] == (
+ 'refs/changes/34/1234/5')
+
api.gerrit.get_change_description(
host, change=123, patchset=1)
diff --git a/recipes/recipe_modules/gerrit/test_api.py b/recipes/recipe_modules/gerrit/test_api.py
index b709bd0976..1824de9a6d 100644
--- a/recipes/recipe_modules/gerrit/test_api.py
+++ b/recipes/recipe_modules/gerrit/test_api.py
@@ -2,15 +2,17 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import copy
+
from recipe_engine import recipe_test_api
# Exemplary change. Note: This contains only a subset of the key/value pairs
# present in production to limit recipe simulation output.
-EXAMPLE_CHANGE = {
+EXAMPLE_RESPONSE = {
'status': 'NEW',
'created': '2017-01-30 13:11:20.000000000',
- '_number': '91827',
+ '_number': 91827,
'change_id': 'Ideadbeef',
'project': 'chromium/src',
'has_review_started': False,
@@ -18,7 +20,7 @@ EXAMPLE_CHANGE = {
'subject': 'Change title',
'revisions': {
'184ebe53805e102605d11f6b143486d15c23a09c': {
- '_number': '1',
+ '_number': 1,
'commit': {
'message': 'Change commit message',
},
@@ -44,10 +46,43 @@ class GerritTestApi(recipe_test_api.RecipeTestApi):
"revision": "67ebf73496383c6777035e374d2d664009e2aa5c"
})
- def get_one_change_response_data(self, **kwargs):
- change = EXAMPLE_CHANGE.copy()
- change.update(kwargs)
- return self._make_gerrit_response_json([change])
+ def get_one_change_response_data(
+ self, branch=None, change=None, project=None, patchset=None, host=None,
+ o_params=None):
+ o_params = o_params or []
+ response = copy.deepcopy(EXAMPLE_RESPONSE)
+ patchset_dict = response['revisions'].values()[0]
+
+ if branch:
+ response['branch'] = branch
+ if change:
+ response['_number'] = int(change)
+ if project:
+ response['project'] = project
+ if patchset:
+ patchset_dict['_number'] = int(patchset)
+
+ if 'DOWNLOAD_COMMANDS' in o_params:
+ patchset_dict['fetch'] = {
+ 'http': {
+ 'url': 'https://chromium.googlesource.com/chromium/src',
+ 'ref': 'refs/changes/27/91827/1',
+ },
+ }
+
+ if host:
+ patchset_dict['fetch']['http']['url'] = host
+ elif project:
+ patchset_dict['fetch']['http']['url'] = (
+ 'https://chromium.googlesource.com/' + project)
+
+ if change or patchset:
+ patchset_dict['fetch']['http']['ref'] = 'refs/changes/{}/{}/{}'.format(
+ str(response['_number'])[-2:],
+ response['_number'],
+ patchset_dict['_number'])
+
+ return self._make_gerrit_response_json([response])
def get_empty_changes_response_data(self):
return self._make_gerrit_response_json([])
diff --git a/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json b/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json
index cf4e40ad87..b5bc5a2f8e 100644
--- a/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json
+++ b/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json
@@ -26,7 +26,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@[@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"_number\": \"91827\", @@@",
+ "@@@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\", @@@",
@@ -34,7 +34,7 @@
"@@@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@ \"_number\": 1, @@@",
"@@@STEP_LOG_LINE@json.output@ \"commit\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"message\": \"Change commit message\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
@@ -49,7 +49,7 @@
},
{
"name": "$result",
- "reason": "Error querying for CL description: host:'https://chromium-review.googlesource.com' change:456789; patchset:12",
+ "reason": "Patchset 12 not found for change 91827",
"recipe_result": null,
"status_code": 1
}