Skip to content

Commit

Permalink
Make sure the versioning scheme ignores any leading v or V.
Browse files Browse the repository at this point in the history
  • Loading branch information
FormerLurker committed Mar 21, 2020
1 parent b1341c8 commit 250c108
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions octoprint_octolapse/test/test_migration_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def test_version(self):

# test stripping off commit level version info
test_version = NumberedVersion('0.4.0rc1+u.dec65f5')
# make sure identical version numbers are considered to be equal
assert (
NumberedVersion('0.4.0rc1') == NumberedVersion('0.4.0rc1')
)

# make sure V prefixes are ignored version numbers are considered to be equal
assert (
NumberedVersion('v0.4.0rc1') == NumberedVersion('0.4.0rc1')
)

# make sure that rc is always greater than rcX.devX
assert (
Expand Down
9 changes: 8 additions & 1 deletion octoprint_octolapse_setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class NumberedVersion(version.LooseVersion):
exists.
'''
def __init__(self, vstring=None, pre_release_tags=['rc'], development_tags=['dev']):
# trim vstring
if vstring != None:
vstring = vstring.strip()
self.pre_release_tags = pre_release_tags
self.development_tags = development_tags
self.original_string = vstring
Expand All @@ -46,7 +49,11 @@ def __init__(self, vstring=None, pre_release_tags=['rc'], development_tags=['dev
self.commit_guid = ''
self.is_dirty = False

# First, find any pluses that contain commit level info
# strip off any leading V or v
if len(vstring) > 0 and vstring[0].upper() == "V":
vstring = vstring[1:]

# find any pluses that contain commit level info
if '+' in vstring:
index = vstring.find('+')
# make sure there is info after the '+'
Expand Down

0 comments on commit 250c108

Please sign in to comment.