Skip to content

Commit f444bdd

Browse files
committed
Add backward compatibility with git < 2.2
1 parent 1686d25 commit f444bdd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

setuptools_git_versioning.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_branches(): # type: () -> List[str]
3434

3535

3636
def get_branch(): # type: () -> Optional[str]
37-
branches = _exec("git branch --show-current")
37+
branches = _exec("git rev-parse --abbrev-ref HEAD")
3838
if branches:
3939
return branches[0]
4040
return None
@@ -54,7 +54,7 @@ def get_tag(): # type: () -> Optional[str]
5454
return None
5555

5656

57-
def get_sha(name): # type: (str) -> Optional[str]
57+
def get_sha(name='HEAD'): # type: (str) -> Optional[str]
5858
sha = _exec("git rev-list -n 1 {name}".format(name=name))
5959
if sha:
6060
return sha[0]
@@ -121,7 +121,7 @@ def version_from_git(template=DEFAULT_TEMPLATE,
121121

122122
dirty = is_dirty()
123123
tag_sha = get_sha(tag)
124-
head_sha = get_sha('HEAD')
124+
head_sha = get_sha()
125125
ccount = count_since(tag)
126126
on_tag = head_sha == tag_sha
127127
branch = get_branch()

0 commit comments

Comments
 (0)