Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
17a8eec2
Unverified
Commit
17a8eec2
authored
May 18, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix version parsing for 4 digits versions and post releases
parent
25953510
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
poetry/semver/patterns.py
+2
-2
poetry/semver/version.py
+17
-0
tests/semver/test_version.py
+4
-0
No files found.
poetry/semver/patterns.py
View file @
17a8eec2
...
...
@@ -2,8 +2,8 @@ import re
MODIFIERS
=
(
'[._-]?'
'((?:beta|b|c|pre|RC|alpha|a|patch|pl|p|dev)(?:(?:[.-]?
\
d+)*)?)?'
'(
(?:[+-]|post)
?([0-9A-Za-z-]+(
\
.[0-9A-Za-z-]+)*))?'
'((?
!post)(?
:beta|b|c|pre|RC|alpha|a|patch|pl|p|dev)(?:(?:[.-]?
\
d+)*)?)?'
'(
[+-]
?([0-9A-Za-z-]+(
\
.[0-9A-Za-z-]+)*))?'
)
_COMPLETE_VERSION
=
'v?(
\
d+)(?:
\
.(
\
d+))?(?:
\
.(
\
d+))?{}(?:
\
+[^
\
s]+)?'
.
format
(
MODIFIERS
)
...
...
poetry/semver/version.py
View file @
17a8eec2
...
...
@@ -50,6 +50,8 @@ class Version(VersionRange):
if
pre
is
not
None
:
self
.
_prerelease
=
self
.
_split_parts
(
pre
)
build
=
self
.
_normalize_build
(
build
)
self
.
_build
=
[]
if
build
is
not
None
:
if
build
.
startswith
((
'-'
,
'+'
)):
...
...
@@ -253,6 +255,21 @@ class Version(VersionRange):
return
'{}.{}'
.
format
(
modifier
,
number
)
def
_normalize_build
(
self
,
build
):
# type: (str) -> str
if
not
build
:
return
if
build
==
'0'
:
return
if
build
.
startswith
(
'post'
):
build
=
build
.
lstrip
(
'post'
)
if
not
build
:
return
return
build
def
_split_parts
(
self
,
text
):
# type: (str) -> List[Union[str, int]]
parts
=
text
.
split
(
'.'
)
...
...
tests/semver/test_version.py
View file @
17a8eec2
...
...
@@ -18,12 +18,16 @@ from poetry.semver import VersionRange
(
'1.0.0-beta.1'
,
Version
(
1
,
0
,
0
,
'beta1'
)),
(
'1.0.0+1'
,
Version
(
1
,
0
,
0
,
None
,
'1'
)),
(
'1.0.0-1'
,
Version
(
1
,
0
,
0
,
None
,
'1'
)),
(
'1.0.0.0'
,
Version
(
1
,
0
,
0
)),
(
'1.0.0-post'
,
Version
(
1
,
0
,
0
)),
(
'1.0.0-post1'
,
Version
(
1
,
0
,
0
,
None
,
'1'
)),
(
'0.6c'
,
Version
(
0
,
6
,
0
,
'rc0'
)),
(
'0.6pre'
,
Version
(
0
,
6
,
0
,
'rc0'
)),
]
)
def
test_parse_valid
(
input
,
version
):
parsed
=
Version
.
parse
(
input
)
print
(
parsed
.
build
)
assert
parsed
==
version
assert
parsed
.
text
==
input
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment