Merge remote-tracking branch 'remotes/bignose-debian/wip/issue/strict-semver-parsing'

This commit is contained in:
Kostiantyn Rybnikov 2016-10-20 12:53:10 +03:00
commit 8533d37514
2 changed files with 26 additions and 5 deletions

View File

@ -21,6 +21,14 @@ Additions
* Add parse_version_info to parse a version string to a version info
tuple.
Bug Fixes
---------
* Refine parsing to conform more strictly to SemVer 2.0.0.
SemVer 2.0.0 specification §9 forbids leading zero on identifiers in
the prerelease version.
Version 2.6.0
=============

View File

@ -10,11 +10,24 @@ __version__ = '2.6.0'
__author__ = 'Konstantine Rybnikov'
__author_email__ = 'k-bx@k-bx.com'
_REGEX = re.compile('^(?P<major>(?:0|[1-9][0-9]*))'
'\.(?P<minor>(?:0|[1-9][0-9]*))'
'\.(?P<patch>(?:0|[1-9][0-9]*))'
'(\-(?P<prerelease>[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?'
'(\+(?P<build>[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$')
_REGEX = re.compile(
r"""
^
(?P<major>(?:0|[1-9][0-9]*))
\.
(?P<minor>(?:0|[1-9][0-9]*))
\.
(?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-]*)*
))?
(\+(?P<build>
[0-9A-Za-z-]+
(\.[0-9A-Za-z-]+)*
))?
$
""", re.VERBOSE)
_LAST_NUMBER = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')