Do not compact a dev-free constraint into a bare != that matches dev - #184
Open
dngr2 wants to merge 1 commit into
Open
Do not compact a dev-free constraint into a bare != that matches dev#184dngr2 wants to merge 1 commit into
dngr2 wants to merge 1 commit into
Conversation
The < N || > N to != N swap in compactConstraint changes dev-branch matching: a bare != N matches every dev-* version, while < N || > N matches none. So "> 1.0.0 != 2.0.0 || < 1.9.0" (matches no branch) compacted to "!= 2.0.0" (matches every branch), and Semver::satisfies flipped after compaction. Skip the swap when it would produce a bare != for a constraint whose branches do not already include all dev versions; a bounded conjunctive != (e.g. [!= 3 < 5]) still keeps a numeric bound and is unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compactConstraint()rewrites< N || > Ninto!= N. Those are not equivalentonce dev versions are involved: a bare
!= Nmatches everydev-*version, while< N || > Nmatches none. So compacting a numeric-only constraint that covers thewhole line except N (and matches no dev branch) into a bare
!=silently startsmatching every dev branch.
Skip the swap when it would produce that bare
!=for a constraint whose branchset isn't already "all dev". A bounded conjunctive
!=such as[!= 3 < 5]keepsa numeric bound and is unaffected.
Added a test that compacts
> 1.0.0 != 2.0.0 || < 1.9.0and checks the result stillexcludes
dev-fooand stays an exact subset of the original both ways.