summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2020-04-29 11:46:24 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2020-04-29 11:46:24 +0200
commit0811fca1c435c1477ee1465578580b491cba6c73 (patch)
treed83ce16c1b5fa1d6a8ee76a0248a9d77f9aedbb8
parenteda1ac8c22a99dbd01cd57fbcd459856b469ae46 (diff)
downloadsemantic-version-0811fca1c435c1477ee1465578580b491cba6c73.tar.gz
Fix wildcard matching for SimpleSpec.
Including docs and tests. Closes #98.
-rw-r--r--ChangeLog5
-rw-r--r--docs/reference.rst9
-rw-r--r--semantic_version/base.py2
-rwxr-xr-xtests/test_base.py10
4 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index b7f41c6..7056f1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,10 @@ ChangeLog
2.8.5 (unreleased)
------------------
-- Nothing changed yet.
+*Bugfix:*
+
+ * `98 <https://github.com/rbarrois/python-semanticversion/issues/98>`_:
+ Properly handle wildcards in ``SimpleSpec`` (e.g. ``==1.2.*``).
2.8.4 (2019-12-21)
diff --git a/docs/reference.rst b/docs/reference.rst
index da08a22..951bd9a 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -472,6 +472,15 @@ Each of those ``Spec`` classes provides a shared set of methods to work with ver
* A clause of ``>0.1.2-rc.3`` will match versions strictly above ``0.1.2-rc.3``, including matching prereleases of ``0.1.2``: ``0.1.2-rc.10`` is included;
* A clause of ``>=XXX`` will match versions that match ``>XXX`` or ``==XXX``
+ ..rubric:: Wildcards
+
+ * A clause of ``==0.1.*`` is equivalent to ``>=0.1.0,<0.2.0``
+ * A clause of ``>=0.1.*`` is equivalent to ``>=0.1.0``
+ * A clause of ``==1.*`` or ``==1.*.*`` is equivalent to ``>=1.0.0,<2.0.0``
+ * A clause of ``>=1.*`` or ``>=1.*.*`` is equivalent to ``>=1.0.0``
+ * A clause of ``==*`` maps to ``>=0.0.0``
+ * A clause of ``>=*`` maps to ``>=0.0.0``
+
.. rubric:: Extensions
Additionnally, python-semanticversion supports extensions from specific packaging platforms:
diff --git a/semantic_version/base.py b/semantic_version/base.py
index 7fd871e..871ccb0 100644
--- a/semantic_version/base.py
+++ b/semantic_version/base.py
@@ -1123,7 +1123,7 @@ class SimpleSpec(BaseSpec):
elif minor is None:
return Range(Range.OP_GTE, target) & Range(Range.OP_LT, target.next_major())
elif patch is None:
- return Range(Range.OP_GTE, target) & Range(Range.OP_LT, target.next_patch())
+ return Range(Range.OP_GTE, target) & Range(Range.OP_LT, target.next_minor())
elif build == '':
return Range(Range.OP_EQ, target, build_policy=Range.BUILD_STRICT)
else:
diff --git a/tests/test_base.py b/tests/test_base.py
index c9770c9..d0a0e81 100755
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -644,6 +644,16 @@ class SpecTestCase(unittest.TestCase):
['0.1.1', '0.1.1+4'],
['0.1.1-alpha', '0.1.2-alpha', '0.1.2', '1.3.4'],
),
+ # 0.1.x
+ '==0.1.*': (
+ ['0.1.1', '0.1.1+4', '0.1.0', '0.1.99'],
+ ['0.1.0-alpha', '0.0.1', '0.2.0'],
+ ),
+ # 1.x.x
+ '==1.*': (
+ ['1.1.1', '1.1.0+4', '1.1.0', '1.99.99'],
+ ['1.0.0-alpha', '0.1.0', '2.0.0'],
+ ),
# At least 0.1.0 with pre-releases, less than 0.1.4 excluding pre-releases,
# neither 0.1.3-rc1 nor any build of that version,
# not 0.1.0+b3 precisely