Skip to content

Commit

Permalink
Fix #37 allow single zero without leading zeros in prerelease version
Browse files Browse the repository at this point in the history
  • Loading branch information
werwolfby committed Nov 8, 2016
1 parent ce3b603 commit 5e41beb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
\.
(?P<patch>(?:0|[1-9][0-9]*))
(\-(?P<prerelease>
[1-9A-Za-z-][0-9A-Za-z-]*
(\.[1-9A-Za-z-][0-9A-Za-z-]*)*
(?:0|[1-9A-Za-z-][0-9A-Za-z-]*)
(\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*
))?
(\+(?P<build>
[0-9A-Za-z-]+
Expand Down
22 changes: 22 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ def test_should_parse_version():
}


def test_should_parse_zero_prerelease():
result = parse("1.2.3-rc.0+build.0")

assert result == {
'major': 1,
'minor': 2,
'patch': 3,
'prerelease': 'rc.0',
'build': 'build.0',
}

result = parse("1.2.3-rc.0.0+build.0")

assert result == {
'major': 1,
'minor': 2,
'patch': 3,
'prerelease': 'rc.0.0',
'build': 'build.0',
}


def test_should_get_less():
assert compare("1.0.0", "2.0.0") == -1

Expand Down

0 comments on commit 5e41beb

Please sign in to comment.