Commit 9198ef8e authored by Nodir Turakulov's avatar Nodir Turakulov Committed by Commit Bot

[bot_update] Default to refs/heads/master

When revision is not specified, currently HEAD is checked out.
Change the default to refs/heads/master

Recipe-Nontrivial-Roll: infra
Recipe-Nontrivial-Roll: build
Recipe-Nontrivial-Roll: build_limited_scripts_slave
Bug: 940214
Change-Id: I8be59095d90447ea898d5247a6433f0734f5e63b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1554862
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
parent 837c8e52
......@@ -52,7 +52,7 @@ Recipe module to ensure a checkout is consistent on a bot.
Wrapper for easy calling of bot_update.
&mdash; **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#452)(self, bot_update_step):**
&mdash; **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#420)(self, bot_update_step):**
Deapplies a patch, taking care of DEPS and solution revisions properly.
......@@ -77,7 +77,7 @@ Args:
When sorting builds by commit position, this commit will be used.
Requires falsy ignore_input_commit.
&mdash; **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#429)(self, project_name, gclient_config=None):**
&mdash; **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#397)(self, project_name, gclient_config=None):**
Returns all property names used for storing the checked-out revision of
a given project.
......
......@@ -105,7 +105,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
assert oauth2_json is None, "oauth2_json is deprecated"
assert not (ignore_input_commit and set_output_commit)
refs = refs or []
refs = list(refs or [])
# We can re-use the gclient spec from the gclient module, since all the
# data bot_update needs is already configured into the gclient spec.
cfg = gclient_config or self.m.gclient.c
......@@ -174,7 +174,11 @@ class BotUpdateApi(recipe_api.RecipeApi):
# TODO(machenbach): We should explicitly pass HEAD for ALL solutions
# that don't specify anything else.
first_sol = cfg.solutions[0].name
revisions[first_sol] = revisions.get(first_sol) or 'HEAD'
revisions[first_sol] = (
revisions.get(first_sol) or
self.m.tryserver.gerrit_change_target_ref or
'refs/heads/master'
)
if cfg.revisions:
# Only update with non-empty values. Some recipe might otherwise
......@@ -195,12 +199,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':
# Sync to correct destination branch if HEAD was specified.
fixed_revision = self._destination_branch(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
fixed_revision != 'refs/heads/master' and
# TODO(crbug.com/874501): fetching additional refs is currently
# only supported for the root solution. We should investigate
# supporting it for other dependencies.
......@@ -310,7 +312,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
assert (
input_commit.ref and
# Revision was not overridden.
revisions[main_repo_path] == input_commit_rev)
revisions[main_repo_path] == input_commit_rev), input_commit
output_commit.ref = input_commit.ref
output_commit.host, output_commit.project = (
self.m.gitiles.parse_repo_url(git_checkout['repo_url']))
......@@ -352,40 +354,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.
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.
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.
"""
# 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 not patch_path or path != patch_path:
return 'HEAD'
target_ref = self.m.tryserver.gerrit_change_target_ref
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
def _resolve_fixed_revisions(self, bot_update_json):
"""Set all fixed revisions from the first sync to their respective
got_X_revision values.
......
......@@ -15,7 +15,7 @@
"--output_json",
"/path/to/tmp/json",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--clobber",
"--disable-syntax-validation"
],
......@@ -31,7 +31,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--disable-syntax-validation"
],
"env_prefixes": {
......@@ -73,7 +73,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -15,7 +15,7 @@
"--output_json",
"/path/to/tmp/json",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--gerrit_no_rebase_patch_ref",
"--disable-syntax-validation"
],
......@@ -31,7 +31,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -15,7 +15,7 @@
"--output_json",
"/path/to/tmp/json",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--gerrit_no_reset",
"--disable-syntax-validation"
],
......@@ -31,7 +31,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -19,7 +19,7 @@
"--patch_ref",
"https://chromium.googlesource.com/v8/v8@refs/changes/124/45/6",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--disable-syntax-validation"
],
"env_prefixes": {
......@@ -34,7 +34,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/angle/angle@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--revision",
"src/third_party/angle@HEAD",
"--disable-syntax-validation"
......@@ -75,7 +75,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src/third_party/angle\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
......
......@@ -15,7 +15,7 @@
"--output_json",
"/path/to/tmp/json",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--refs",
"+refs/change/1/2/333",
"--disable-syntax-validation"
......@@ -32,7 +32,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--disable-syntax-validation"
],
"env_prefixes": {
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--disable-syntax-validation"
],
"env_prefixes": {
......@@ -74,7 +74,7 @@
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"failed_patch_body\": \"Downloading patch...\\nApplying the patch...\\nPatch: foo/bar.py\\nIndex: foo/bar.py\\ndiff --git a/foo/bar.py b/foo/bar.py\\nindex HASH..HASH MODE\\n--- a/foo/bar.py\\n+++ b/foo/bar.py\\ncontext\\n+something\\n-something\\nmore context\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--disable-syntax-validation"
],
"env_prefixes": {
......@@ -74,7 +74,7 @@
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"failed_patch_body\": \"Downloading patch...\\nApplying the patch...\\nPatch: foo/bar.py\\nIndex: foo/bar.py\\ndiff --git a/foo/bar.py b/foo/bar.py\\nindex HASH..HASH MODE\\n--- a/foo/bar.py\\n+++ b/foo/bar.py\\ncontext\\n+something\\n-something\\nmore context\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/angle/angle@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--revision",
"src/third_party/angle@HEAD",
"--disable-syntax-validation"
......@@ -75,7 +75,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src/third_party/angle\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
......
......@@ -75,7 +75,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/branch-heads/67\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -58,7 +58,9 @@
"--patch_ref",
"https://chromium.googlesource.com/chromium/src@refs/changes/56/123456/7",
"--revision",
"src@experimental/feature",
"src@refs/heads/experimental/feature",
"--refs",
"refs/heads/experimental/feature",
"--disable-syntax-validation"
],
"env_prefixes": {
......@@ -73,7 +75,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/experimental/feature\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -58,9 +58,11 @@
"--patch_ref",
"https://chromium.googlesource.com/v8/v8@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/experimental/feature",
"--revision",
"src/v8@experimental/feature",
"src/v8@HEAD",
"--refs",
"refs/heads/experimental/feature",
"--disable-syntax-validation"
],
"env_prefixes": {
......@@ -75,7 +77,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/experimental/feature\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src/v8\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://webrtc.googlesource.com/src@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--revision",
"src/third_party/webrtc@HEAD",
"--disable-syntax-validation"
......@@ -75,7 +75,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src/third_party/webrtc\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/v8/v8@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--revision",
"src/v8@abc",
"--disable-syntax-validation"
......@@ -75,7 +75,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src/v8\": \"abc\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
......
......@@ -58,7 +58,7 @@
"--patch_ref",
"https://chromium.googlesource.com/v8/v8@refs/changes/56/123456/7",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--revision",
"src/v8@HEAD",
"--disable-syntax-validation"
......@@ -75,7 +75,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\", @@@",
"@@@STEP_LOG_LINE@json.output@ \"src/v8\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
......
......@@ -15,7 +15,7 @@
"--output_json",
"/path/to/tmp/json",
"--revision",
"src@HEAD",
"src@refs/heads/master",
"--with_tags",
"--disable-syntax-validation"
],
......@@ -31,7 +31,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"src\": {@@@",
......
......@@ -15,7 +15,7 @@
"--output_json",
"/path/to/tmp/json",
"--revision",
"depot_tools@HEAD"
"depot_tools@refs/heads/master"
],
"env_prefixes": {
"PATH": [
......@@ -29,7 +29,7 @@
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@",
"@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"depot_tools\": \"HEAD\"@@@",
"@@@STEP_LOG_LINE@json.output@ \"depot_tools\": \"refs/heads/master\"@@@",
"@@@STEP_LOG_LINE@json.output@ }, @@@",
"@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"depot_tools\": {@@@",
......
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