From f61af56950276661d14c5c3387a706692487ecab Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Tue, 30 Apr 2019 17:35:52 +0000 Subject: [PATCH] bot_update: Pass target-ref to gclient. Bug: 956807 Recipe-Nontrivial-Roll: infra Recipe-Nontrivial-Roll: skia Recipe-Nontrivial-Roll: build_limited_scripts_slave Recipe-Nontrivial-Roll: build Change-Id: I4d786d989446b8c1e3f39ef78c3c99cfe70808c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1588502 Commit-Queue: Edward Lesmes Reviewed-by: Andrii Shyshkalov --- recipes/recipe_modules/bot_update/api.py | 34 +++++++++---------- .../deprecated_got_revision_mapping.json | 2 +- .../no_apply_patch_on_gclient.json | 2 +- .../examples/full.expected/tryjob_fail.json | 2 +- .../full.expected/tryjob_fail_patch.json | 2 +- .../tryjob_fail_patch_download.json | 2 +- .../full.expected/tryjob_gerrit_angle.json | 2 +- .../tryjob_gerrit_branch_heads.json | 2 +- .../tryjob_gerrit_feature_branch.json | 6 ++-- .../tryjob_gerrit_v8_feature_branch.json | 4 +-- .../full.expected/tryjob_gerrit_webrtc.json | 2 +- .../examples/full.expected/tryjob_v8.json | 2 +- .../tryjob_v8_head_by_default.json | 2 +- 13 files changed, 33 insertions(+), 31 deletions(-) diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py index 0504d7779a..c189ecc154 100644 --- a/recipes/recipe_modules/bot_update/api.py +++ b/recipes/recipe_modules/bot_update/api.py @@ -143,8 +143,12 @@ class BotUpdateApi(recipe_api.RecipeApi): if patch: repo_url = self.m.tryserver.gerrit_change_repo_url fetch_ref = self.m.tryserver.gerrit_change_fetch_ref + target_ref = self.m.tryserver.gerrit_change_target_ref if repo_url and fetch_ref: - flags.append(['--patch_ref', '%s@%s' % (repo_url, fetch_ref)]) + flags.append([ + '--patch_ref', + '%s@%s:%s' % (repo_url, target_ref, fetch_ref), + ]) if patch_refs: flags.extend( ['--patch_ref', patch_ref] @@ -195,8 +199,8 @@ class BotUpdateApi(recipe_api.RecipeApi): if fixed_revision: fixed_revisions[name] = fixed_revision if fixed_revision.upper() == 'HEAD': - # Sync to correct destination branch if HEAD was specified. - fixed_revision = self._destination_branch(cfg, name) + # Sync to correct destination ref if HEAD was specified. + fixed_revision = self._destination_ref(cfg, name) # 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 @@ -368,13 +372,13 @@ 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. + def _destination_ref(self, cfg, path): + """Returns the ref branch of a CL for the matching project if available or + HEAD otherwise. If there's no Gerrit CL associated with the run, returns 'HEAD'. - Otherwise this queries Gerrit for the correct destination branch, which - might differ from master. + Otherwise this queries Gerrit for the correct destination ref, which + might differ from refs/heads/master. Args: cfg: The used gclient config. @@ -382,11 +386,13 @@ class BotUpdateApi(recipe_api.RecipeApi): '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. + A destination ref as understood by bot_update.py if available + and if different from refs/heads/master, returns 'HEAD' otherwise. """ # Ignore project paths other than the one belonging to the current CL. patch_path = self.m.gclient.get_gerrit_patch_root(gclient_config=cfg) + if patch_path: + patch_path = patch_path.replace(self.m.path.sep, '/') if not patch_path or path != patch_path: return 'HEAD' @@ -394,13 +400,7 @@ class BotUpdateApi(recipe_api.RecipeApi): if target_ref == 'refs/heads/master': return 'HEAD' - # TODO: Remove. Return ref, not branch. - ret = target_ref - prefix = 'refs/heads/' - if ret.startswith(prefix): - ret = ret[len(prefix):] - - return ret + return target_ref def _resolve_fixed_revisions(self, bot_update_json): """Set all fixed revisions from the first sync to their respective diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json b/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json index d023d167da..a3ef456ccf 100644 --- a/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +++ b/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7", + "https://chromium.googlesource.com/chromium/src@refs/heads/master:refs/changes/56/123456/7", "--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 6585883124..9f89fc7473 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 @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/angle/angle@refs/changes/56/123456/7", + "https://chromium.googlesource.com/angle/angle@refs/heads/master:refs/changes/56/123456/7", "--revision", "src@HEAD", "--revision", diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json index 309d650224..53cd173c66 100644 --- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7", + "https://chromium.googlesource.com/chromium/src@refs/heads/master:refs/changes/56/123456/7", "--revision", "src@HEAD", "--disable-syntax-validation" diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json index 97c19c2a3f..28f676ef49 100644 --- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7", + "https://chromium.googlesource.com/chromium/src@refs/heads/master:refs/changes/56/123456/7", "--revision", "src@HEAD", "--disable-syntax-validation" diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json index f68a58caae..c0dfc29057 100644 --- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7", + "https://chromium.googlesource.com/chromium/src@refs/heads/master:refs/changes/56/123456/7", "--revision", "src@HEAD", "--disable-syntax-validation" 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 6585883124..9f89fc7473 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 @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/angle/angle@refs/changes/56/123456/7", + "https://chromium.googlesource.com/angle/angle@refs/heads/master:refs/changes/56/123456/7", "--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 2a26c65d06..7f5d24d6eb 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 @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7", + "https://chromium.googlesource.com/chromium/src@refs/branch-heads/67:refs/changes/56/123456/7", "--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 ec55b8b635..e577f4a9e0 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 @@ -56,9 +56,11 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7", + "https://chromium.googlesource.com/chromium/src@refs/heads/experimental/feature:refs/changes/56/123456/7", "--revision", - "src@experimental/feature", + "src@refs/heads/experimental/feature", + "--refs", + "refs/heads/experimental/feature", "--disable-syntax-validation" ], "env_prefixes": { 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 8436eec161..45993fe0d1 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 @@ -56,11 +56,11 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/v8/v8@refs/changes/56/123456/7", + "https://chromium.googlesource.com/v8/v8@refs/heads/experimental/feature:refs/changes/56/123456/7", "--revision", "src@HEAD", "--revision", - "src/v8@experimental/feature", + "src/v8@refs/heads/experimental/feature", "--disable-syntax-validation" ], "env_prefixes": { 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 b388861806..8a16463e2c 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 @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://webrtc.googlesource.com/src@refs/changes/56/123456/7", + "https://webrtc.googlesource.com/src@refs/heads/master:refs/changes/56/123456/7", "--revision", "src@HEAD", "--revision", diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json index caec2ba035..04ad2bb0aa 100644 --- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/v8/v8@refs/changes/56/123456/7", + "https://chromium.googlesource.com/v8/v8@refs/heads/master:refs/changes/56/123456/7", "--revision", "src@HEAD", "--revision", 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 0490db83be..9c5eab7568 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 @@ -56,7 +56,7 @@ "--output_json", "/path/to/tmp/json", "--patch_ref", - "https://chromium.googlesource.com/v8/v8@refs/changes/56/123456/7", + "https://chromium.googlesource.com/v8/v8@refs/heads/master:refs/changes/56/123456/7", "--revision", "src@HEAD", "--revision",