Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NpmSpec Comparison Between Prerelease Versions is Wrong #100

Open
arjunaskykok opened this issue Jun 12, 2020 · 6 comments
Open

NpmSpec Comparison Between Prerelease Versions is Wrong #100

arjunaskykok opened this issue Jun 12, 2020 · 6 comments
Labels
Topic:NPM Implementing NPM-style version specifiers Type:Bug

Comments

@arjunaskykok
Copy link

arjunaskykok commented Jun 12, 2020

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.

@arjunaskykok arjunaskykok changed the title NpmSpec Comparison Involving Alpha Version is Wrong NpmSpec Comparison Between Prerelease Versions is Wrong Jun 12, 2020
@rbarrois
Copy link
Owner

This looks indeed like a bug; I don't understand why the current tests fail to detect it :/

@rbarrois rbarrois added Topic:NPM Implementing NPM-style version specifiers Type:Bug labels Jun 15, 2020
@arjunaskykok
Copy link
Author

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
Copy link

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
Copy link

oh and the same issue with ~2.0.1- not matching anything

@tysonliddell
Copy link

tysonliddell commented Dec 15, 2022

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
Copy link

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Topic:NPM Implementing NPM-style version specifiers Type:Bug
Projects
None yet
Development

No branches or pull requests

5 participants