From 08f3e313a4ed6442b03f072bc85d706b696cff57 Mon Sep 17 00:00:00 2001 From: "Rakib M. Hasan" Date: Tue, 10 Aug 2021 21:34:52 +0000 Subject: [PATCH] Allow users to specify the revision of the root solution checkout This CL allows users to pass the root solution revision to the bot update step for presubmits. The presubmit for some child repositories of src have dependencies on src. We need to make sure that the same branch of a src and child repositories are checked out. Bug:1238418 Change-Id: If2ea3962d764bddd17b3d17d20e7c644f4065fe0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3085094 Reviewed-by: Gavin Mak Reviewed-by: Dirk Pranke Reviewed-by: Garrett Beaty Commit-Queue: Rakib Hasan --- recipes/README.recipes.md | 7 +++++-- recipes/recipe_modules/presubmit/api.py | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 78ea261f5..b848d2b9b 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -806,7 +806,7 @@ Raises: Returns a presubmit step. -— **def [execute](/recipes/recipe_modules/presubmit/api.py#100)(self, bot_update_step, skip_owners=False):** +— **def [execute](/recipes/recipe_modules/presubmit/api.py#110)(self, bot_update_step, skip_owners=False):** Runs presubmit and sets summary markdown if applicable. @@ -817,7 +817,7 @@ Args: Returns: a RawResult object, suitable for being returned from RunSteps. -— **def [prepare](/recipes/recipe_modules/presubmit/api.py#65)(self):** +— **def [prepare](/recipes/recipe_modules/presubmit/api.py#65)(self, root_solution_revision=None):** Sets up a presubmit run. @@ -828,6 +828,9 @@ This includes: This expects the gclient configuration to already have been set. +Args: + root_solution_revision: revision of the root solution + Returns: the StepResult from the bot_update step. diff --git a/recipes/recipe_modules/presubmit/api.py b/recipes/recipe_modules/presubmit/api.py index 05c0cb070..75d1ec288 100644 --- a/recipes/recipe_modules/presubmit/api.py +++ b/recipes/recipe_modules/presubmit/api.py @@ -62,7 +62,7 @@ class PresubmitApi(recipe_api.RecipeApi): output[key] = output2[key] return output - def prepare(self): + def prepare(self, root_solution_revision=None): """Sets up a presubmit run. This includes: @@ -72,13 +72,23 @@ class PresubmitApi(recipe_api.RecipeApi): This expects the gclient configuration to already have been set. + Args: + root_solution_revision: revision of the root solution + Returns: the StepResult from the bot_update step. """ - # Expect callers to have already set up their gclient configuration. + # Set up the root solution revision by either passing the revision + # to this function or adding it to the input properties. + root_solution_revision = ( + root_solution_revision or + self.m.properties.get('root_solution_revision')) + # Expect callers to have already set up their gclient configuration. bot_update_step = self.m.bot_update.ensure_checkout( - timeout=3600, no_fetch_tags=True) + timeout=3600, no_fetch_tags=True, + root_solution_revision=root_solution_revision) + relative_root = self.m.gclient.get_gerrit_patch_root().rstrip('/') abs_root = self.m.context.cwd.join(relative_root)