diff options
author | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2019-11-21 12:45:28 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2019-11-21 13:13:19 +0100 |
commit | da55cf15dd71a0d9a839e7507e4fc69396c8326d (patch) | |
tree | 9fa88a3fab1f631ab82f5329f4ec0ad71fd01023 | |
parent | 371faaf6453b07f5316e356e68d7f26ae44b0df9 (diff) | |
download | semantic-version-da55cf15dd71a0d9a839e7507e4fc69396c8326d.tar.gz |
Fix NpmSpec prerelease-handling.
Thanks to Nathan Walters for spotting this.
Npm ranges with a `<X.Y.Z-P` component were not properly expanded:
they were converted to:
<X.Y.0 || (>=X.Y.0 && <X.Y.Z-P && no-prerelease)
The correct expansion is:
<X.Y.0 || (>=X.Y.0-* && <X.Y.Z-P)
Closes #86.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | semantic_version/base.py | 3 | ||||
-rw-r--r-- | tests/test_npm.py | 4 |
3 files changed, 13 insertions, 2 deletions
@@ -4,7 +4,13 @@ ChangeLog 2.8.3 (unreleased) ------------------ -- Nothing changed yet. +*New:* + - Add `Clause.prettyprint()` for debugging + +*Bugfix:* + + * `#86 <https://github.com/rbarrois/python-semanticversion/issues/86>`_: + Fix handling of prerelease ranges within `NpmSpec` 2.8.2 (2019-09-06) diff --git a/semantic_version/base.py b/semantic_version/base.py index 4327fa1..1b0bac5 100644 --- a/semantic_version/base.py +++ b/semantic_version/base.py @@ -1273,7 +1273,7 @@ class NpmSpec(BaseSpec): prerelease_policy=Range.PRERELEASE_ALWAYS, )) elif clause.operator in (Range.OP_LT, Range.OP_LTE): - prerelease_clauses.append(cls.range( + prerelease_clauses.append(Range( operator=Range.OP_GTE, target=Version( major=clause.target.major, @@ -1281,6 +1281,7 @@ class NpmSpec(BaseSpec): patch=0, prerelease=(), ), + prerelease_policy=Range.PRERELEASE_ALWAYS, )) prerelease_clauses.append(clause) non_prerel_clauses.append(cls.range( diff --git a/tests/test_npm.py b/tests/test_npm.py index 7bed337..da3f5ba 100644 --- a/tests/test_npm.py +++ b/tests/test_npm.py @@ -40,6 +40,10 @@ class NpmSpecTests(unittest.TestCase): ['1.2.3-alpha.3', '1.2.3-alpha.7', '3.4.5'], ['1.2.3-alpha.2', '3.4.5-alpha.9'], ), + '>1.2.3-alpha <1.2.3-beta': ( + ['1.2.3-alpha.0', '1.2.3-alpha.1'], + ['1.2.3', '1.2.3-beta.0', '1.2.3-bravo'], + ), '1.2.3 - 2.3.4': ( ['1.2.3', '1.2.99', '2.2.0', '2.3.4', '2.3.4+b42'], ['1.2.0', '1.2.3-alpha.1', '2.3.5'], |