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

Fix NPM spec less comparison with prerelease bug. #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arjunaskykok
Copy link

This PR fixes this bug: #100.

@rbarrois
Copy link
Owner

Thanks for the contribution! Could you explain why this fixes the bug? Ideally in comments or the commit message, but I can add it myself — as long as I understand it :D

@arjunaskykok
Copy link
Author

@rbarrois So without the fix, this is what happens.

>>> from semantic_version import NpmSpec, Version
>>> NpmSpec("<1.2.3-beta.7").clause
AnyOf(AllOf(Range('<', Version('1.2.3'), prerelease_policy='same-patch')), AllOf(Range('<', Version('1.2.3-beta.7'), prerelease_policy='same-patch'), Range('>=', Version('1.2.0'), prerelease_policy='always')))

Notice there is this clause AllOf(Range('<', Version('1.2.3'), prerelease_policy='same-patch')), so every prerelease (alpha-1,2,3,4,..., beta-1,2,3,4,...., rc-1,2,3,4,....) version always matches because versions 1.2.3-rc.4 or 1.2.3-alpha.7 or 1.2.3-beta.8 is always less than version 1.2.3. Basically, my fix removes this clause.

To be fair, I consider my patch as a quick fix, not as a holistic one. I don't fully understand how NPM spec matching engine works. :)

I mean I can update the PR to add a comment but I just need to make sure you are okay with my patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants