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: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md
index d83d7b8..3b526b5 100644
--- a/recipes/README.recipes.md
+++ b/recipes/README.recipes.md
@@ -63,7 +63,7 @@
Deapplies a patch, taking care of DEPS and solution revisions properly.
-— **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):**
+— **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 @@
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.
— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#506)(self, project_name, gclient_config=None):**
@@ -869,7 +869,7 @@
Set the gerrit change for this module.
Args:
- * cl: a GerritChange object.
+ * change: a self.m.buildbucket.common_pb2.GerritChange.
— **def [set\_compile\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#196)(self):**
diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py
index 10c5e5f..2ab8aed 100644
--- a/recipes/recipe_modules/bot_update/api.py
+++ b/recipes/recipe_modules/bot_update/api.py
@@ -88,7 +88,7 @@
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 @@
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 @@
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')
diff --git a/recipes/recipe_modules/tryserver/api.py b/recipes/recipe_modules/tryserver/api.py
index 3716dd3..b87d03c 100644
--- a/recipes/recipe_modules/tryserver/api.py
+++ b/recipes/recipe_modules/tryserver/api.py
@@ -261,12 +261,12 @@
"""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)