Skip to content

Commit b0c25bd

Browse files
staticfloatKristofferC
authored andcommitted
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 d117975)
1 parent 851436b commit b0c25bd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

base/version_git.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ if [ -n "$(git status --porcelain)" ]; then
4141
# append dirty mark '*' if the repository has uncommitted changes
4242
commit_short="$commit_short"*
4343
fi
44-
branch=$(git rev-parse --abbrev-ref HEAD)
44+
45+
# Our CI system checks commits out as a detached head, and so we must
46+
# use the provided branch name, as we cannot autodetect this commit as
47+
# the tip of any such branch.
48+
if [ -n "${BUILDKITE_BRANCH}" ]; then
49+
branch="${BUILDKITE_BRANCH}"
50+
else
51+
branch=$(git rev-parse --abbrev-ref HEAD)
52+
fi
4553

4654
topdir=$(git rev-parse --show-toplevel)
4755
verchanged=$(git blame -L ,1 -sl -- "$topdir/VERSION" | cut -f 1 -d " ")

0 commit comments

Comments
 (0)