Ronny Pfannschmidt avatar Ronny Pfannschmidt committed 98c422b

fix misshandling dirty worktree in a tag commit

Comments (0)

Files changed (2)

 import sys
 import shlex
 import subprocess
+import datetime
 
 def trace_debug(*k):
     sys.stdout.write(' '.join(map(str,k)))
 
 def _version(tag, distance=0, node=None, dirty=False):
     tag = tag_to_version(tag)
+    time = datetime.date.today().strftime('%Y%m%d')
     return locals()
 
 
 
 
 def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
+    dirty = node.endswith('+')
+    node = node.strip('+')
     st = do('hg st --no-status --change %s' % str(node), root)
 
     trace('normalize', locals())
-    if int(dist) == 1 and st == '.hgtags':
+    if int(dist) == 1 and st == '.hgtags' and not dirty:
         return _version(tag)
     else:
-        return _version(tag, distance=dist, node=node)
+        return _version(tag, distance=dist, node=node, dirty=dirty)
 
 
 def version_from_hg15_parents(root, cachefile=None):

test_hgdistver.py

 import os
+import re
 import py
 import pytest
 
     assert after_tag_01 == '0.1'
 
     tmpdir.join('test.txt').write('test2')
+
+    after_tag_01_with_changes = get_version(cwd, method=method)
+    regex = r'0.1.post1-.{12}\+\d+$'
+    assert re.match(regex, after_tag_01_with_changes)
+
     do('hg commit -m commit2 -u test -d "0 0"', cwd)
 
     second_after_tag_01 = get_version(cwd, method=method)
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.