|
|
@ -4,18 +4,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
"""Recipe module to ensure a checkout is consistent on a bot."""
|
|
|
|
"""Recipe module to ensure a checkout is consistent on a bot."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
from recipe_engine import recipe_api
|
|
|
|
from recipe_engine import recipe_api
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BotUpdateApi(recipe_api.RecipeApi):
|
|
|
|
class BotUpdateApi(recipe_api.RecipeApi):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, properties, patch_issue, patch_set, patch_ref,
|
|
|
|
def __init__(self, properties, patch_issue, patch_set, repository,
|
|
|
|
patch_gerrit_url, deps_revision_overrides, fail_patch, *args,
|
|
|
|
patch_repository_url, patch_ref, patch_gerrit_url,
|
|
|
|
**kwargs):
|
|
|
|
deps_revision_overrides, fail_patch, *args, **kwargs):
|
|
|
|
self._apply_patch_on_gclient = properties.get(
|
|
|
|
self._apply_patch_on_gclient = properties.get(
|
|
|
|
'apply_patch_on_gclient', True)
|
|
|
|
'apply_patch_on_gclient', True)
|
|
|
|
self._issue = patch_issue
|
|
|
|
self._issue = patch_issue
|
|
|
|
self._patchset = patch_set
|
|
|
|
self._patchset = patch_set
|
|
|
|
|
|
|
|
self._repository = repository or patch_repository_url
|
|
|
|
self._gerrit_ref = patch_ref
|
|
|
|
self._gerrit_ref = patch_ref
|
|
|
|
self._gerrit = patch_gerrit_url
|
|
|
|
self._gerrit = patch_gerrit_url
|
|
|
|
self._deps_revision_overrides = deps_revision_overrides
|
|
|
|
self._deps_revision_overrides = deps_revision_overrides
|
|
|
@ -25,9 +28,11 @@ class BotUpdateApi(recipe_api.RecipeApi):
|
|
|
|
super(BotUpdateApi, self).__init__(*args, **kwargs)
|
|
|
|
super(BotUpdateApi, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(self):
|
|
|
|
def initialize(self):
|
|
|
|
assert len(self.m.buildbucket.build.input.gerrit_changes) <= 1, (
|
|
|
|
changes = self.m.buildbucket.build.input.gerrit_changes
|
|
|
|
'bot_update does not support more than one '
|
|
|
|
if self._repository is None and len(changes) == 1:
|
|
|
|
'buildbucket.build.input.gerrit_changes')
|
|
|
|
cl = changes[0]
|
|
|
|
|
|
|
|
host = re.sub(r'([^\.]+)-review(\.googlesource\.com)', r'\1\2', cl.host)
|
|
|
|
|
|
|
|
self._repository = 'https://%s/%s' % (host, cl.project)
|
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, name, cmd, **kwargs):
|
|
|
|
def __call__(self, name, cmd, **kwargs):
|
|
|
|
"""Wrapper for easy calling of bot_update."""
|
|
|
|
"""Wrapper for easy calling of bot_update."""
|
|
|
@ -106,14 +111,13 @@ class BotUpdateApi(recipe_api.RecipeApi):
|
|
|
|
assert cfg is not None, (
|
|
|
|
assert cfg is not None, (
|
|
|
|
'missing gclient_config or forgot api.gclient.set_config(...) before?')
|
|
|
|
'missing gclient_config or forgot api.gclient.set_config(...) before?')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Construct our bot_update command. This basically be inclusive of
|
|
|
|
# Construct our bot_update command. This basically be inclusive of
|
|
|
|
# everything required for bot_update to know:
|
|
|
|
# everything required for bot_update to know:
|
|
|
|
root = patch_root
|
|
|
|
root = patch_root
|
|
|
|
if root is None:
|
|
|
|
if root is None:
|
|
|
|
# TODO(nodir): use m.gclient.get_repo_path instead.
|
|
|
|
|
|
|
|
root = self.m.gclient.calculate_patch_root(
|
|
|
|
root = self.m.gclient.calculate_patch_root(
|
|
|
|
self.m.properties.get('patch_project'), cfg,
|
|
|
|
self.m.properties.get('patch_project'), cfg, self._repository)
|
|
|
|
self.m.tryserver.gerrit_change_repo_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Allow patch_project's revision if necessary.
|
|
|
|
# Allow patch_project's revision if necessary.
|
|
|
|
# This is important for projects which are checked out as DEPS of the
|
|
|
|
# This is important for projects which are checked out as DEPS of the
|
|
|
@ -138,10 +142,9 @@ class BotUpdateApi(recipe_api.RecipeApi):
|
|
|
|
|
|
|
|
|
|
|
|
# How to find the patch, if any
|
|
|
|
# How to find the patch, if any
|
|
|
|
if patch:
|
|
|
|
if patch:
|
|
|
|
if self.m.tryserver.gerrit_change_repo_url and self._gerrit_ref:
|
|
|
|
if self._repository and self._gerrit_ref:
|
|
|
|
flags.append(
|
|
|
|
flags.append(
|
|
|
|
['--patch_ref', '%s@%s' % (
|
|
|
|
['--patch_ref', '%s@%s' % (self._repository, self._gerrit_ref)])
|
|
|
|
self.m.tryserver.gerrit_change_repo_url, self._gerrit_ref)])
|
|
|
|
|
|
|
|
if patch_refs:
|
|
|
|
if patch_refs:
|
|
|
|
flags.extend(
|
|
|
|
flags.extend(
|
|
|
|
['--patch_ref', patch_ref]
|
|
|
|
['--patch_ref', patch_ref]
|
|
|
|