Skip to content

Commit 404094f

Browse files
Merge branch 'hbasria/master' into master
2 parents bda1b52 + 5caa8e0 commit 404094f

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Bugfixes:
1919
* fix #321: add suppport for the ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${DISTRIBUTION_NAME}`` env var to target the pretend key
2020
* fix #142: clearly list supported scm
2121
* fix #213: better error message for non-zero dev numbers in tags
22-
22+
* fix #356: add git branch to version on describe failure
2323

2424
v4.1.2
2525
=======

src/setuptools_scm/git.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,16 @@ def parse(
106106
out, unused_err, ret = wd.do_ex(describe_command)
107107
if ret:
108108
# If 'git git_describe_command' failed, try to get the information otherwise.
109+
branch, branch_err, branch_ret = wd.do_ex("git symbolic-ref --short HEAD")
110+
111+
if branch_ret:
112+
branch = None
113+
109114
rev_node = wd.node()
110115
dirty = wd.is_dirty()
111116

112117
if rev_node is None:
113-
return meta("0.0", distance=0, dirty=dirty, config=config)
118+
return meta("0.0", distance=0, dirty=dirty, branch=branch, config=config)
114119

115120
return meta(
116121
"0.0",

testing/test_git.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def test_parse_call_order(wd):
8080
def test_version_from_git(wd):
8181
assert wd.version == "0.1.dev0"
8282

83+
assert git.parse(str(wd.cwd), git.DEFAULT_DESCRIBE).branch == "master"
84+
8385
wd.commit_testfile()
8486
assert wd.version.startswith("0.1.dev1+g")
8587
assert not wd.version.endswith("1-")

0 commit comments

Comments
 (0)