From f9747f4c419c1886b9ca0255a301e1853692c1d8 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 13 Oct 2016 08:33:19 +0200 Subject: [PATCH 1/5] add test for #109 --- testing/test_git.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing/test_git.py b/testing/test_git.py index c3ae002d..1e34f7d6 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -34,8 +34,12 @@ def test_version_from_git(wd): @pytest.mark.issue(108) +@pytest.mark.issue(109) def test_git_worktree(wd): wd.write('test.txt', 'test2') + # untracked files dont change the state + assert wd.version == '0.1.dev0' + wd('git add test.txt') assert wd.version.startswith('0.1.dev0+d') From 812b80a44891cd9b331bb5a3d229f8d02b0be094 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 13 Oct 2016 08:35:29 +0200 Subject: [PATCH 2/5] ignore untracked files in worktree, fixes #109 --- setuptools_scm/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setuptools_scm/git.py b/setuptools_scm/git.py index 10280e50..2b4e19de 100644 --- a/setuptools_scm/git.py +++ b/setuptools_scm/git.py @@ -30,7 +30,7 @@ def from_potential_worktree(cls, wd): return cls(real_wd) def is_dirty(self): - out, _, _ = self.do_ex("git status --porcelain") + out, _, _ = self.do_ex("git status --porcelain --untracked-files=no") return bool(out) def node(self): From 73071051b984504cf98872e28084384dd74046b9 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 13 Oct 2016 08:36:12 +0200 Subject: [PATCH 3/5] fix oversight - when git node is None, distance should be 0 --- setuptools_scm/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setuptools_scm/git.py b/setuptools_scm/git.py index 2b4e19de..aa326f36 100644 --- a/setuptools_scm/git.py +++ b/setuptools_scm/git.py @@ -50,7 +50,7 @@ def parse(root, describe_command=DEFAULT_DESCRIBE): dirty = wd.is_dirty() if rev_node is None: - return meta('0.0', dirty=dirty) + return meta('0.0', distance=0, dirty=dirty) out, err, ret = do_ex(describe_command, root) if ret: From 5515c958b9c1314731f73f1561dac9e7c0fb7db6 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 13 Oct 2016 08:37:41 +0200 Subject: [PATCH 4/5] fix tests after ensuring distance is 0 --- testing/test_git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_git.py b/testing/test_git.py index 1e34f7d6..7179a574 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -14,7 +14,7 @@ def wd(wd): def test_version_from_git(wd): - assert wd.version == '0.0' + assert wd.version == '0.1.dev0' wd.commit_testfile() assert wd.version.startswith('0.1.dev1+') From de40adc12b36f76279c972fa0ebaa5ae01bdadd4 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 13 Oct 2016 08:40:46 +0200 Subject: [PATCH 5/5] add CHANGELOG entries --- CHANGELOG.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 32391876..385ac83b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,12 @@ +v1.14.1 +======= + +* fix #109: when detecting a dirty git workdir + don't consider untracked file + (this was a regression due to #86 in v1.13.1) +* consider the distance 0 when the git node is unknown + (happens when you haven't commited anything) + v1.14.0 =======