Commit 44473361 authored by Xinan Lin's avatar Xinan Lin Committed by LUCI CQ

Improve the setup logic for tryserver

If the given change does not have a valid gerrit host name, stop
initializing the tryserver module.
Also polished the variable name and docstr added in crrev/c/2528670.

Recipe-Nontrivial-Roll: infra
Bug:1146487
Change-Id: I38193b25d37c724fd41d898eb020237fbf7cecdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2544000
Commit-Queue: Xinan Lin <linxinan@chromium.org>
Reviewed-by: 's avatarNodir Turakulov <nodir@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@google.com>
parent 829ce021
......@@ -63,7 +63,7 @@ Wrapper for easy calling of bot_update.
Deapplies a patch, taking care of DEPS and solution revisions properly.
&mdash; **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#71)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, no_fetch_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, accept_buildbucket_input=True, disable_syntax_validation=False, patch_refs=None, ignore_input_commit=False, add_blamelists=False, set_output_commit=False, step_test_data=None, enforce_fetch=False, \*\*kwargs):**
&mdash; **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#71)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, no_fetch_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, accept_input_gerrit_changes=True, disable_syntax_validation=False, patch_refs=None, ignore_input_commit=False, add_blamelists=False, set_output_commit=False, step_test_data=None, enforce_fetch=False, \*\*kwargs):**
Args:
* gclient_config: The gclient configuration to use when running bot_update.
......@@ -90,11 +90,11 @@ Args:
Use test_api.output_json to generate test data.
* enforce_fetch: Enforce a new fetch to refresh the git cache, even if the
solution revision passed in already exists in the current git cache.
* accept_buildbucket_input: should get the patchset from
buildbucket.build.input.gerrit_changes. If True, the input size is
asserted to be one, because bot_update module ONLY supports one CL.
Users may specify a CL via tryserver.set_change() and explicitly set
this flag False.
* accept_input_gerrit_changes: if True, get the patchset from
self.m.buildbucket.build.input.gerrit_changes, with an assertion that
the size of self.m.buildbucket.build.input.gerrit_changes is one,
because bot_update module ONLY supports one change. Users may specify a
change via tryserver.set_change() and explicitly set this flag False.
&mdash; **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#506)(self, project_name, gclient_config=None):**
......@@ -869,7 +869,7 @@ Returns true iff we have a change to check out.
Set the gerrit change for this module.
Args:
* cl: a GerritChange object.
* change: a self.m.buildbucket.common_pb2.GerritChange.
&mdash; **def [set\_compile\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#196)(self):**
......
......@@ -88,7 +88,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
patchset=None,
gerrit_no_reset=False,
gerrit_no_rebase_patch_ref=False,
accept_buildbucket_input=True,
accept_input_gerrit_changes=True,
disable_syntax_validation=False,
patch_refs=None,
ignore_input_commit=False,
......@@ -123,11 +123,11 @@ class BotUpdateApi(recipe_api.RecipeApi):
Use test_api.output_json to generate test data.
* enforce_fetch: Enforce a new fetch to refresh the git cache, even if the
solution revision passed in already exists in the current git cache.
* accept_buildbucket_input: should get the patchset from
buildbucket.build.input.gerrit_changes. If True, the input size is
asserted to be one, because bot_update module ONLY supports one CL.
Users may specify a CL via tryserver.set_change() and explicitly set
this flag False.
* accept_input_gerrit_changes: if True, get the patchset from
self.m.buildbucket.build.input.gerrit_changes, with an assertion that
the size of self.m.buildbucket.build.input.gerrit_changes is one,
because bot_update module ONLY supports one change. Users may specify a
change via tryserver.set_change() and explicitly set this flag False.
"""
assert use_site_config_creds is None, "use_site_config_creds is deprecated"
assert rietveld is None, "rietveld is deprecated"
......@@ -136,7 +136,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
assert patch_oauth2 is None, "patch_oauth2 is deprecated"
assert oauth2_json is None, "oauth2_json is deprecated"
assert not (ignore_input_commit and set_output_commit)
if accept_buildbucket_input:
if accept_input_gerrit_changes:
assert len(self.m.buildbucket.build.input.gerrit_changes) <= 1, (
'bot_update does not support more than one '
'buildbucket.build.input.gerrit_changes')
......
......@@ -261,12 +261,12 @@ class TryserverApi(recipe_api.RecipeApi):
"""Set the gerrit change for this module.
Args:
* cl: a GerritChange object.
* change: a self.m.buildbucket.common_pb2.GerritChange.
"""
self._gerrit_info_initialized = False
self._gerrit_change = change
git_host = change.host
gs_suffix = '-review.googlesource.com'
if git_host.endswith(gs_suffix):
git_host = '%s.googlesource.com' % git_host[:-len(gs_suffix)]
self._gerrit_change_repo_url = 'https://%s/%s' % (git_host, change.project)
if change.host.endswith(gs_suffix):
self._gerrit_info_initialized = False
self._gerrit_change = change
git_host = '%s.googlesource.com' % change.host[:-len(gs_suffix)]
self._gerrit_change_repo_url = 'https://%s/%s' % (git_host,
change.project)
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