Skip to content

Commit ee8ce47

Browse files
Merge pull request #160 from sschuberth/per-scm-prefix
Use per-SCM node prefix letters instead of the general "n"
2 parents 83b751c + 016d71f commit ee8ce47

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ and uses roughly the following logic to render the version:
114114
:code:`no distance and clean`:
115115
:code:`{tag}`
116116
:code:`distance and clean`:
117-
:code:`{next_version}.dev{distance}+n{revision hash}`
117+
:code:`{next_version}.dev{distance}+{scm letter}{revision hash}`
118118
:code:`no distance and not clean`:
119119
:code:`{tag}+dYYYMMMDD`
120120
:code:`distance and not clean`:
121-
:code:`{next_version}.dev{distance}+n{revision hash}.dYYYMMMDD`
121+
:code:`{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYMMMDD`
122122

123123
The next version is calculated by adding ``1`` to the last numeric component
124124
of the tag.

setuptools_scm/hg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
99
dirty = node.endswith('+')
10-
node = node.strip('+')
10+
node = 'h' + node.strip('+')
1111
revset = ("(branch(.) and tag({tag!r})::. and file('re:^(?!\.hgtags).*$')"
1212
" - tag({tag!r}))").format(tag=tag)
1313
if tag != '0.0':
@@ -58,14 +58,17 @@ def parse(root):
5858

5959
def archival_to_version(data):
6060
trace('data', data)
61+
node = data.get('node', '')[:12]
62+
if node:
63+
node = 'h' + node
6164
if 'tag' in data:
6265
return meta(data['tag'])
6366
elif 'latesttag' in data:
6467
return meta(data['latesttag'],
6568
distance=data['latesttagdistance'],
66-
node=data['node'][:12])
69+
node=node)
6770
else:
68-
return meta('0.0', node=data.get('node', '')[:12])
71+
return meta('0.0', node=node)
6972

7073

7174
def parse_archival(root):

setuptools_scm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def get_local_node_and_date(version):
125125
if version.exact or version.node is None:
126126
return version.format_choice("", "+d{time:%Y%m%d}")
127127
else:
128-
return version.format_choice("+n{node}", "+n{node}.d{time:%Y%m%d}")
128+
return version.format_choice("+{node}", "+{node}.d{time:%Y%m%d}")
129129

130130

131131
def get_local_dirty_tag(version):

testing/test_git.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ def test_version_from_git(wd):
1919
assert wd.version == '0.1.dev0'
2020

2121
wd.commit_testfile()
22-
assert wd.version.startswith('0.1.dev1+')
22+
assert wd.version.startswith('0.1.dev1+g')
2323
assert not wd.version.endswith('1-')
2424

2525
wd('git tag v0.1')
2626
assert wd.version == '0.1'
2727

2828
wd.write('test.txt', 'test2')
29-
assert wd.version.startswith('0.2.dev0+')
29+
assert wd.version.startswith('0.2.dev0+g')
3030

3131
wd.commit_testfile()
32-
assert wd.version.startswith('0.2.dev1+')
32+
assert wd.version.startswith('0.2.dev1+g')
3333

3434
wd('git tag version-0.2')
3535
assert wd.version.startswith('0.2')
@@ -101,4 +101,4 @@ def test_parse_no_worktree(tmpdir):
101101
def test_alphanumeric_tags_match(wd):
102102
wd.commit_testfile()
103103
wd('git tag newstyle-development-started')
104-
assert wd.version.startswith('0.1.dev1+')
104+
assert wd.version.startswith('0.1.dev1+g')

testing/test_mercurial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def wd(wd):
1515

1616
archival_mapping = {
1717
'1.0': {'tag': '1.0'},
18-
'1.1.dev3+n000000000000': {
18+
'1.1.dev3+h000000000000': {
1919
'latesttag': '1.0',
2020
'latesttagdistance': '3',
2121
'node': '0'*20,
@@ -91,7 +91,7 @@ def test_version_from_archival(wd):
9191
'latesttagdistance: 3\n'
9292
)
9393

94-
assert wd.version == '0.2.dev3+n000000000000'
94+
assert wd.version == '0.2.dev3+h000000000000'
9595

9696

9797
@pytest.mark.issue('#72')

0 commit comments

Comments
 (0)