From c6e57bb748380489c67d7f680627f09734c01845 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Mon, 30 Apr 2018 12:19:59 -0700 Subject: [PATCH] bot_update: really check whether repo is pinned at an actual sha1 revision. Previously, anything not equal to HEAD meant pinned revision. This backfired on values like "origin/master" which are meant as equivalent to HEAD, but which bot_update tried to ensure exist in checkout, which was refreshed several times under assumption that this is eventual consistency of git servers. Instead, this CL treats repo as pinned if and only if the treeish of the repo is matching sha1 regex. R=hinoka@chromium.org Bug: 838292 Change-Id: I9cb46535f46b2898cf54900ede7960ba08770d77 Post-Scriptum: git bisect + Led is awesome, took only 8 manual steps. Reviewed-on: https://chromium-review.googlesource.com/1035793 Reviewed-by: Ryan Tseng Commit-Queue: Andrii Shyshkalov --- recipes/recipe_modules/bot_update/resources/bot_update.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipes/recipe_modules/bot_update/resources/bot_update.py b/recipes/recipe_modules/bot_update/resources/bot_update.py index b3c8241d7..3e5361875 100755 --- a/recipes/recipe_modules/bot_update/resources/bot_update.py +++ b/recipes/recipe_modules/bot_update/resources/bot_update.py @@ -41,6 +41,9 @@ CHROMIUM_SRC_URL = CHROMIUM_GIT_HOST + '/chromium/src.git' BRANCH_HEADS_REFSPEC = '+refs/branch-heads/*' TAGS_REFSPEC = '+refs/tags/*' +# Regular expression to match sha1 git revision. +COMMIT_HASH_RE = re.compile(r'[0-9a-f]{5,40}', re.IGNORECASE) + # Regular expression that matches a single commit footer line. COMMIT_FOOTER_ENTRY_RE = re.compile(r'([^:]+):\s*(.*)') @@ -550,7 +553,7 @@ def get_target_pin(solution_name, git_url, revisions): """Returns revision to be checked out if it is pinned, else None.""" _, revision = _get_target_branch_and_revision( solution_name, git_url, revisions) - if revision.upper() != 'HEAD': + if COMMIT_HASH_RE.match(revision): return revision return None