Fix handling pre-1.0.0 caret versions (Closes #35)
Thanks to @autopulated for pointing the issue!
This commit is contained in:
parent
9872b3940e
commit
d10ab4cb1d
|
@ -1,6 +1,15 @@
|
|||
ChangeLog
|
||||
=========
|
||||
|
||||
|
||||
2.5.1 (master)
|
||||
--------------
|
||||
|
||||
*Bugfix:*
|
||||
|
||||
* `#35 <https://github.com/rbarrois/python-semanticversion/issues/35>`_:
|
||||
Properly handle `^0.X.Y` in a NPM-compatible way
|
||||
|
||||
2.5.0 (2016-02-12)
|
||||
------------------
|
||||
|
||||
|
|
|
@ -459,7 +459,13 @@ class SpecItem(object):
|
|||
elif self.kind == self.KIND_NEQ:
|
||||
return version != self.spec
|
||||
elif self.kind == self.KIND_CARET:
|
||||
return self.spec <= version < self.spec.next_major()
|
||||
if self.spec.major != 0:
|
||||
upper = self.spec.next_major()
|
||||
elif self.spec.minor != 0:
|
||||
upper = self.spec.next_minor()
|
||||
else:
|
||||
upper = self.spec.next_patch()
|
||||
return self.spec <= version < upper
|
||||
elif self.kind == self.KIND_TILDE:
|
||||
return self.spec <= version < self.spec.next_minor()
|
||||
else: # pragma: no cover
|
||||
|
|
|
@ -506,6 +506,14 @@ class SpecItemTestCase(unittest.TestCase):
|
|||
['1.1.3', '1.2.1', '1.1.2-alpha', '1.1.2-alpha+b1'],
|
||||
['1.1.1', '2.1.0'],
|
||||
),
|
||||
'^0.1.2': (
|
||||
['0.1.2', '0.1.2-alpha', '0.1.3'],
|
||||
['0.2.0', '1.1.2', '0.1.1'],
|
||||
),
|
||||
'^0.0.2': (
|
||||
['0.0.2', '0.0.2-alpha', '0.0.2+abb'],
|
||||
['0.1.0', '0.0.3', '1.0.0'],
|
||||
),
|
||||
}
|
||||
|
||||
def test_matches(self):
|
||||
|
|
|
@ -106,7 +106,7 @@ class MatchTestCase(unittest.TestCase):
|
|||
'0.1.2',
|
||||
'0.1.2+build4.5',
|
||||
'0.1.3-rc1.3',
|
||||
'0.2.0',
|
||||
'0.1.4',
|
||||
],
|
||||
'~0.1.2': [
|
||||
'0.1.2',
|
||||
|
|
Loading…
Reference in New Issue