Skip to content

Commit d17972e

Browse files
committed
Extract functions for each bump technique.
1 parent 2743575 commit d17972e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

setuptools_scm/version.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,23 @@ def meta(tag, distance=None, dirty=False, node=None, **kw):
8989

9090
def guess_next_version(tag_version, distance):
9191
version = str(tag_version)
92-
if '.dev' in version:
93-
prefix, tail = version.rsplit('.dev', 1)
94-
assert tail == '0', 'own dev numbers are unsupported'
95-
else:
96-
prefix, tail = re.match('(.*?)(\d+)$', version).groups()
97-
prefix = '%s%d' % (prefix, int(tail) + 1)
92+
bumped = _bump_dev(version) or _bump_regex(version)
9893
suffix = '.dev%s' % distance
99-
return prefix + suffix
94+
return bumped + suffix
95+
96+
97+
def _bump_dev(version):
98+
if '.dev' not in version:
99+
return
100+
101+
prefix, tail = version.rsplit('.dev', 1)
102+
assert tail == '0', 'own dev numbers are unsupported'
103+
return prefix
104+
105+
106+
def _bump_regex(version):
107+
prefix, tail = re.match('(.*?)(\d+)$', version).groups()
108+
return '%s%d' % (prefix, int(tail) + 1)
100109

101110

102111
def guess_next_dev_version(version):

0 commit comments

Comments
 (0)