From 1fa0450a3f2db8eb134ce38f40a3bf35e2d0ab32 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Fri, 15 Jul 2022 13:43:58 -0700 Subject: [PATCH] Allow `BUILDKITE_BRANCH` to provide branch name (#46053) * Allow `BUILDKITE_BRANCH` to provide branch name Our CI system checks commits out as a detached head, which breaks our `Base.GIT_VERSION_INFO.branch` information. * Fix typo (cherry picked from commit d117975aa629bee97901a2c132f028adf23d16ae) --- base/version_git.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/base/version_git.sh b/base/version_git.sh index 957626508d67e..e2c0454ed0796 100644 --- a/base/version_git.sh +++ b/base/version_git.sh @@ -41,7 +41,15 @@ if [ -n "$(git status --porcelain)" ]; then # append dirty mark '*' if the repository has uncommitted changes commit_short="$commit_short"* fi -branch=$(git rev-parse --abbrev-ref HEAD) + +# Our CI system checks commits out as a detached head, and so we must +# use the provided branch name, as we cannot autodetect this commit as +# the tip of any such branch. +if [ -n "${BUILDKITE_BRANCH}" ]; then + branch="${BUILDKITE_BRANCH}" +else + branch=$(git rev-parse --abbrev-ref HEAD) +fi topdir=$(git rev-parse --show-toplevel) verchanged=$(git blame -L ,1 -sl -- "$topdir/VERSION" | cut -f 1 -d " ")