Commit 02e59414 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

Fix bot_update's usage of the destination branch

The previously passed branch:HEAD notation is understood by bot_update
for the main project, but not by gclient for deps'ed projects.

We don't need the colon notation at all as passing a branch implies
using the HEAD of that branch.

Bug: 740456
Change-Id: I95eb88f0de2e06bee8a3e7db24c4ad85cdb76d3e
Reviewed-on: https://chromium-review.googlesource.com/566866Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
parent 83eb1cd5
......@@ -225,8 +225,8 @@ class BotUpdateApi(recipe_api.RecipeApi):
if fixed_revision:
fixed_revisions[name] = fixed_revision
if fixed_revision.upper() == 'HEAD':
# Prefix with correct destination branch if HEAD was specified.
fixed_revision = self._destination_branch_prefix(cfg, name) + 'HEAD'
# Sync to correct destination branch if HEAD was specified.
fixed_revision = self._destination_branch(cfg, name)
flags.append(['--revision', '%s@%s' % (name, fixed_revision)])
# Add extra fetch refspecs.
......@@ -333,9 +333,9 @@ class BotUpdateApi(recipe_api.RecipeApi):
def enable_destination_branch_check(self):
self._enable_destination_branch_check = True
def _destination_branch_prefix(self, cfg, path):
"""Returns the destination branch prefix of a CL for the matching project
if available.
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
......@@ -347,20 +347,20 @@ 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 prefix as understood by bot_update.py if available
and if different from master, an empty string otherwise.
A destination branch as understood by bot_update.py if available
and if different from master, returns 'HEAD' otherwise.
"""
# Bail out if the feature is not enabled or if this is not a gerrit issue.
if (not self._enable_destination_branch_check or
not self.m.tryserver.is_gerrit_issue or
not self._gerrit or not self._issue):
return ''
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 ''
return 'HEAD'
# Query Gerrit to check if a CL's destination branch differs from master.
destination_branch = self.m.gerrit.get_change_destination_branch(
......@@ -370,7 +370,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
)
# Only use prefix if different from bot_update.py's default.
return destination_branch + ':' if destination_branch != 'master' else ''
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
......
......@@ -65,7 +65,7 @@
"--output_json",
"/path/to/tmp/json",
"--revision",
"src@experimental/feature:HEAD",
"src@experimental/feature",
"--disable-syntax-validation"
],
"env_prefixes": {
......
......@@ -67,7 +67,7 @@
"--revision",
"src@HEAD",
"--revision",
"src/v8@experimental/feature:HEAD",
"src/v8@experimental/feature",
"--disable-syntax-validation"
],
"env_prefixes": {
......
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