Ronny Pfannschmidt avatar Ronny Pfannschmidt committed c1a2f63

consider git dirty mark

Comments (0)

Files changed (2)

                 )
     )
     out, err = p.communicate()
-    trace('out', repr(out))
-    trace('err', repr(err))
-    trace('ret', p.returncode)
+    if out:
+        trace('out', repr(out))
+    if err:
+        trace('err', repr(err))
+    if p.returncode:
+        trace('ret', p.returncode)
     return out.strip().decode(), err.strip().decode(), p.returncode
 
 def do(cmd, cwd='.'):
         return _version('0.0', distance=count + 1, node=out)
     if ret:
         return
+    dirty = out.endswith('-dirty')
+    if dirty:
+        out = out.rsplit('-', 1)[0]
     if '-' not in out:
-        return _version(out)
+        return _version(out, node=rev_node[:7], dirty=dirty)
     else:
         tag, number, node = out.split('-')
-        return _version(tag, distance=number, node=node)
+        return _version(tag, distance=number, node=node, dirty=dirty)
 
 
 def _archival_to_version(data):
     if not isinstance(version, dict):
         return version
     elif version['dirty']:
-        return "%(tag)s.post%(distance)s-%(node)s+%(stime)s" % version
+        return "%(tag)s.post%(distance)s-%(node)s+%(time)s" % version
     elif version['distance']:
         return "%(tag)s.post%(distance)s-%(node)s" % version
     else:

test_hgdistver.py

     assert at_tag_01 == '0.1'
 
     tmpdir.join('test.txt').write('test2')
+    dirty_tag_01 = get_version(cwd)
+    assert dirty_tag_01.startswith('0.1.post0-')
     do('git add test.txt', cwd)
     do('git commit -m commit', cwd)
     after_tag_01 = get_version(cwd)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.