Skip to content

Commit 5538f19

Browse files
fix issue #86 - detect dirty git workdir without tags
1 parent 9f360e6 commit 5538f19

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

setuptools_scm/git.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ def parse(root, describe_command=DEFAULT_DESCRIBE):
2525
count = revs.count('\n')
2626
if ret:
2727
out = rev_node
28-
return meta('0.0', distance=count + 1, node=out)
28+
git_dirt = do('git describe --always --dirty')
29+
return meta(
30+
'0.0',
31+
distance=count + 1,
32+
node=out,
33+
dirty=git_dirt.endswith('-dirty'),
34+
)
2935
if ret:
3036
return
3137
dirty = out.endswith('-dirty')

testing/test_git.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from setuptools_scm import integration
22
import pytest
3+
from datetime import date
34

45

56
@pytest.fixture
@@ -32,6 +33,17 @@ def test_version_from_git(wd):
3233
assert wd.version.startswith('0.2')
3334

3435

36+
@pytest.mark.issue(86)
37+
def test_git_dirty_notag(wd):
38+
wd.commit_testfile()
39+
wd.write('test.txt', 'test2')
40+
wd("git add test.txt")
41+
assert wd.version.startswith('0.1.dev1')
42+
today = date.today()
43+
# we are dirty, check for the tag
44+
assert today.strftime('.d%Y%m%d') in wd.version
45+
46+
3547
def test_find_files_stop_at_root_git(wd):
3648
wd.commit_testfile()
3749
wd.cwd.ensure('project/setup.cfg')

0 commit comments

Comments
 (0)