From 18785bb297bf4c3db076e5ae10a9c42edebde59f Mon Sep 17 00:00:00 2001 From: Garrett Beaty Date: Fri, 3 Dec 2021 18:28:49 +0000 Subject: [PATCH] Fix the environment for calling git number. Calling git number requires that that depot tools is on the path so that git-number can be found and requires the CHROME_HEADLESS environment variable to be set. Change-Id: Iabb8ec6732ca2bcc0f3209449e23a7d0a4f629e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3314033 Auto-Submit: Garrett Beaty Reviewed-by: Gavin Mak Commit-Queue: Gavin Mak --- recipes/README.recipes.md | 2 +- recipes/recipe_modules/git/__init__.py | 1 + recipes/recipe_modules/git/api.py | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 76c1910d1..df947ba4f 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -375,7 +375,7 @@ Returns: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#submit-change ### *recipe_modules* / [git](/recipes/recipe_modules/git) -[DEPS](/recipes/recipe_modules/git/__init__.py#3): [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step] +[DEPS](/recipes/recipe_modules/git/__init__.py#3): [depot\_tools](#recipe_modules-depot_tools), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step] PYTHON_VERSION_COMPATIBILITY: PY2+3 diff --git a/recipes/recipe_modules/git/__init__.py b/recipes/recipe_modules/git/__init__.py index 8e6c8e090..b49b0a490 100644 --- a/recipes/recipe_modules/git/__init__.py +++ b/recipes/recipe_modules/git/__init__.py @@ -1,6 +1,7 @@ PYTHON_VERSION_COMPATIBILITY = 'PY2+3' DEPS = [ + 'depot_tools', 'recipe_engine/buildbucket', 'recipe_engine/context', 'recipe_engine/runtime', diff --git a/recipes/recipe_modules/git/api.py b/recipes/recipe_modules/git/api.py index fe548fb7c..605e59b14 100644 --- a/recipes/recipe_modules/git/api.py +++ b/recipes/recipe_modules/git/api.py @@ -451,7 +451,12 @@ class GitApi(recipe_api.RecipeApi): args = ['number'] args.extend(commitrefs or []) - step_result = self(*args, - stdout=self.m.raw_io.output_text(add_output_log=True), - step_test_data=step_test_data) + # Put depot_tools on the path so that git-number can be found + with self.m.depot_tools.on_path(): + # git-number is only meant for use on bots, so it prints an error message + # if CHROME_HEADLESS is not set + with self.m.context(env={'CHROME_HEADLESS': '1'}): + step_result = self(*args, + stdout=self.m.raw_io.output_text(add_output_log=True), + step_test_data=step_test_data) return [l.strip() for l in step_result.stdout.strip().splitlines()]