diff options
author | Ronny Pfannschmidt <ronny.pfannschmidt@redhat.com> | 2020-12-11 23:05:59 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <ronny.pfannschmidt@redhat.com> | 2020-12-11 23:05:59 +0100 |
commit | 404094fea56fdef55a1e1d2ffbf343f5e9701b8b (patch) | |
tree | a0a74e27de1f6dcb1013cce970172907ea2b2877 | |
parent | bda1b523f77e15e62a788641c7e6dd41c24a1576 (diff) | |
parent | 5caa8e07a0ed94311e9f243829aafbaa1f7fe3e6 (diff) | |
download | setuptools-scm-404094fea56fdef55a1e1d2ffbf343f5e9701b8b.tar.gz |
Merge branch 'hbasria/master' into master
-rw-r--r-- | CHANGELOG.rst | 2 | ||||
-rw-r--r-- | src/setuptools_scm/git.py | 7 | ||||
-rw-r--r-- | testing/test_git.py | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 83666ae..12bf230 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,7 +19,7 @@ Bugfixes: * fix #321: add suppport for the ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${DISTRIBUTION_NAME}`` env var to target the pretend key * fix #142: clearly list supported scm * fix #213: better error message for non-zero dev numbers in tags - +* fix #356: add git branch to version on describe failure v4.1.2 ======= diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py index 4fd5d49..a193f93 100644 --- a/src/setuptools_scm/git.py +++ b/src/setuptools_scm/git.py @@ -106,11 +106,16 @@ def parse( out, unused_err, ret = wd.do_ex(describe_command) if ret: # If 'git git_describe_command' failed, try to get the information otherwise. + branch, branch_err, branch_ret = wd.do_ex("git symbolic-ref --short HEAD") + + if branch_ret: + branch = None + rev_node = wd.node() dirty = wd.is_dirty() if rev_node is None: - return meta("0.0", distance=0, dirty=dirty, config=config) + return meta("0.0", distance=0, dirty=dirty, branch=branch, config=config) return meta( "0.0", diff --git a/testing/test_git.py b/testing/test_git.py index 1b57fed..8eb8583 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -80,6 +80,8 @@ def test_parse_call_order(wd): def test_version_from_git(wd): assert wd.version == "0.1.dev0" + assert git.parse(str(wd.cwd), git.DEFAULT_DESCRIBE).branch == "master" + wd.commit_testfile() assert wd.version.startswith("0.1.dev1+g") assert not wd.version.endswith("1-") |