Repository: pypa/setuptools_scm

Issue:
empty history results in distance None
`1.11.1` gets `0.0` there
recent releases get `0.1.dev0+nnone.d20161011)`

Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 35b1322..3239187 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -2,6 +2,7 @@ v1.14.0
 =======
 
 * publish bdist_egg for python 2.6, 2.7 and 3.3-3.5
+* fix issue #107 - dont use node if it is None
 
 v1.13.1
 =======
diff --git a/setuptools_scm/version.py b/setuptools_scm/version.py
index 40bd89d..b255eef 100644
--- a/setuptools_scm/version.py
+++ b/setuptools_scm/version.py
@@ -106,7 +106,7 @@ def guess_next_dev_version(version):
 
 
 def get_local_node_and_date(version):
-    if version.exact:
+    if version.exact or version.node is None:
         return version.format_choice("", "+d{time:%Y%m%d}")
     else:
         return version.format_choice("+n{node}", "+n{node}.d{time:%Y%m%d}")


Test patch:
diff --git a/testing/test_functions.py b/testing/test_functions.py
index eae9e9c..f5e5d87 100644
--- a/testing/test_functions.py
+++ b/testing/test_functions.py
@@ -30,15 +30,15 @@ VERSIONS = {
 
 @pytest.mark.parametrize('version,scheme,expected', [
     ('exact', 'guess-next-dev node-and-date', '1.1'),
-    ('zerodistance', 'guess-next-dev node-and-date', '1.2.dev0+nNone'),
-    ('dirty', 'guess-next-dev node-and-date', '1.2.dev0+nNone.dtime'),
-    ('distance', 'guess-next-dev node-and-date', '1.2.dev3+nNone'),
-    ('distancedirty', 'guess-next-dev node-and-date', '1.2.dev3+nNone.dtime'),
+    ('zerodistance', 'guess-next-dev node-and-date', '1.2.dev0'),
+    ('dirty', 'guess-next-dev node-and-date', '1.2.dev0+dtime'),
+    ('distance', 'guess-next-dev node-and-date', '1.2.dev3'),
+    ('distancedirty', 'guess-next-dev node-and-date', '1.2.dev3+dtime'),
     ('exact', 'post-release node-and-date', '1.1'),
-    ('zerodistance', 'post-release node-and-date', '1.1.post0+nNone'),
-    ('dirty', 'post-release node-and-date', '1.1.post0+nNone.dtime'),
-    ('distance', 'post-release node-and-date', '1.1.post3+nNone'),
-    ('distancedirty', 'post-release node-and-date', '1.1.post3+nNone.dtime'),
+    ('zerodistance', 'post-release node-and-date', '1.1.post0'),
+    ('dirty', 'post-release node-and-date', '1.1.post0+dtime'),
+    ('distance', 'post-release node-and-date', '1.1.post3'),
+    ('distancedirty', 'post-release node-and-date', '1.1.post3+dtime'),
 ])
 def test_format_version(version, monkeypatch, scheme, expected):
     version = VERSIONS[version]
diff --git a/testing/test_git.py b/testing/test_git.py
index 0819fad..c3ae002 100644
--- a/testing/test_git.py
+++ b/testing/test_git.py
@@ -33,6 +33,12 @@ def test_version_from_git(wd):
     assert wd.version.startswith('0.2')
 
 
+@pytest.mark.issue(108)
+def test_git_worktree(wd):
+    wd.write('test.txt', 'test2')
+    assert wd.version.startswith('0.1.dev0+d')
+
+
 @pytest.mark.issue(86)
 def test_git_dirty_notag(wd):
     wd.commit_testfile()