NpmSpec Comparison Between Prerelease Versions is Wrong
Opened this issue ยท 6 comments
arjunaskykok commented
Version is 2.8.5.
>>> from semantic_version import NpmSpec, Version
>>> NpmSpec("<0.1.1-alpha.1").match(Version("0.1.1-beta.1"))
True
>>> NpmSpec("<0.1.1-alpha.1").match(Version("0.1.1-rc.1"))
True
>>> NpmSpec("<0.1.1-beta.7").match(Version("0.1.1-beta.8"))
True
They should be false.
rbarrois commented
This looks indeed like a bug; I don't understand why the current tests fail to detect it :/
arjunaskykok commented
Because you only test '>1.2.3-alpha.3' and '>=1.2.3-alpha.3' cases (GT and GTE). No cases for prerelease versions with LT and LTE. :)
smiller171 commented
possibly related:
>>> NpmSpec(">=2.0.1-").match(Version("2.0.1-rc1"))
False
>>> NpmSpec(">=2.0.1-0").match(Version("2.0.1-rc1"))
True
I believe >=2.0.1-
should match all 2.0.1 prerelease versions of 2.0.1
, but in actuality you need to add some character after the -
smiller171 commented
oh and the same issue with ~2.0.1-
not matching anything
tysonliddell commented
Here's another example that doesn't seem correct.
>>> from semantic_version import NpmSpec, Version
>>> NpmSpec("5.4.0-alpha.0").match(Version("5.4.0-alpha.0"))
True
>>> NpmSpec("5.4.0-alpha.0").match(Version("5.4.0"))
True # this should be False
The same examples in semver
from npm have the correct logic:
> var semver = require('semver');
> semver.satisfies('2.0.0-next.1', '2.0.0-next.1');
true
> semver.satisfies('2.0.0', '2.0.0-next.1');
false
SpecialK118 commented
Any news about this?
I also encountered it (with jquery-ui that selected the beta version instead of latest stable).
> NpmSpec('<1.14.0').select([Version('1.13.3'), Version('1.14.0-beta.1')])
Version('1.14.0-beta.1')