diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2019-08-23 19:26:24 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2019-08-24 15:13:09 +0200 |
commit | c24f4e2157438be40b44e6ba02d90c6bfa934454 (patch) | |
tree | 66ecf2747c6a605688c0a934d94bab539085c11e /semantic_version | |
parent | 13902f1812697bac01ea1172663a6eedd20ac9d5 (diff) | |
download | semantic-version-c24f4e2157438be40b44e6ba02d90c6bfa934454.tar.gz |
Fix inconsistent matching behaviour.
According to the stated goal of "intuitive" behaviour, we want:
``Version('0.1.1-a1') not in Spec('<0.1.1')``.
Tests, code and docs have been fixed.
Diffstat (limited to 'semantic_version')
-rw-r--r-- | semantic_version/base.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/semantic_version/base.py b/semantic_version/base.py index 8251efa..1caffa5 100644 --- a/semantic_version/base.py +++ b/semantic_version/base.py @@ -441,7 +441,7 @@ class Version: base_cmp, # Major is still mandatory make_optional(base_cmp), make_optional(base_cmp), - make_optional(prerelease_cmp), + prerelease_cmp, make_optional(build_cmp), ] else: @@ -568,6 +568,8 @@ class SpecItem: if self.kind == self.KIND_ANY: return True elif self.kind == self.KIND_LT: + if version.prerelease and self.spec.prerelease is None: + version = Version(major=version.major, minor=version.minor, patch=version.patch) return version < self.spec elif self.kind == self.KIND_LTE: return version <= self.spec @@ -578,6 +580,8 @@ class SpecItem: elif self.kind == self.KIND_GT: return version > self.spec elif self.kind == self.KIND_NEQ: + if version.prerelease and version.truncate() == self.spec.truncate() and self.spec.prerelease is None: + return False return version != self.spec elif self.kind == self.KIND_CARET: if self.spec.major != 0: |