Skip to content

Commit 31ea46d

Browse files
committed
Use CHANGE_BRANCH env.variable for build_info.git_branch
1 parent 3575fc8 commit 31ea46d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

ci/ext.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,11 @@ def generate_build_info(mode=None, strict=False):
450450
# get the date of the commit (HEAD), as a Unix timestamp
451451
git_date = shell_cmd(["git", "show", "-s", "--format=%ct", "HEAD"],
452452
strict=strict)
453-
git_branch = shell_cmd(["git", "rev-parse", "--abbrev-ref", "HEAD"],
454-
strict=strict)
453+
if "CHANGE_BRANCH" in os.environ:
454+
git_branch = os.environ["CHANGE_BRANCH"]
455+
else:
456+
git_branch = shell_cmd(["git", "rev-parse", "--abbrev-ref", "HEAD"],
457+
strict=strict)
455458
git_diff = shell_cmd(["git", "diff", "HEAD", "--stat", "--no-color"],
456459
strict=strict)
457460
# Reformat the `git_date` as a UTC time string

docs/api/dt/build_info.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343

4444
.. xparam:: .git_branch: str
4545

46-
Name of the git branch from where the build was made, as
47-
obtained from ``git rev-parse --abbrev-ref HEAD``.
46+
Name of the git branch from where the build was made. This will
47+
be obtained from environment variable ``CHANGE_BRANCH`` if defined,
48+
or from command ``git rev-parse --abbrev-ref HEAD`` otherwise.
4849

4950

5051
.. xparam:: .git_date: str

0 commit comments

Comments
 (0)