Correctly handle prereleases/ANY ranges in subset#377
Merged
Conversation
isaacs
added a commit
that referenced
this pull request
Mar 23, 2021
An "ANY" range (ie, `""`, `*`, etc.) does not include prerelease versions except when `includePrerelease` flag is set. Also, merely looking at the max/min boundaries of any ranges ignores the fact that the sub range maybe including prerelease versions that are excluded from the super range. For example, `>=1.2.3-pre.0` is _not_ a subset of `>=1.0.0`, because it inludes `1.2.3-pre.0`, `1.2.3-pre.1`, and so on. PR-URL: #377 Credit: @isaacs Close: #377 Reviewed-by: @isaacs
cc1ab36 to
57813f7
Compare
An "ANY" range (ie, `""`, `*`, etc.) does not include prerelease versions except when `includePrerelease` flag is set. Also, merely looking at the max/min boundaries of any ranges ignores the fact that the sub range maybe including prerelease versions that are excluded from the super range. For example, `>=1.2.3-pre.0` is _not_ a subset of `>=1.0.0`, because it inludes `1.2.3-pre.0`, `1.2.3-pre.1`, and so on. PR-URL: #377 Credit: @isaacs Close: #377 Reviewed-by: @wraithgar
57813f7 to
0ce87d6
Compare
This was referenced Mar 23, 2021
ghost
reviewed
Mar 23, 2021
ghost
left a comment
There was a problem hiding this comment.
Ahh, seems I was a bit too late 🙈 I just had a few minor suggestions, but it looks good, though! Still trying to wrap my head around the range comparisons for pre-releases includePrerelease, that's what was taking me a bit 😋 Thanks for addressing this! Much appreciated 😊👍
| // - If LT.semver is greater than any < or <= comp in C, return false | ||
| // - If LT is <=, and LT.semver does not satisfy every C, return false | ||
| // - If any C is a = range, and GT or LT are set, return false | ||
| // - If GT.semver has a prerelease, and not in prerelease mode |
There was a problem hiding this comment.
I think this should be the following (could be wrong):
Suggested change
| // - If GT.semver has a prerelease, and not in prerelease mode | |
| // - If LT.semver has a prerelease, and not in prerelease mode |
| ['>2 <1', '3', true], | ||
| ['1 || 2 || 3', '>=1.0.0', true], | ||
|
|
||
| // everything is a subset of * |
There was a problem hiding this comment.
This comment should probably say something new, since this is not always true 😅
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.
An "ANY" range (ie,
"",*, etc.) does not include prereleaseversions except when
includePrereleaseflag is set.Also, merely looking at the max/min boundaries of any ranges ignores the
fact that the sub range maybe including prerelease versions that are
excluded from the super range. For example,
>=1.2.3-pre.0is not asubset of
>=1.0.0, because it inludes1.2.3-pre.0,1.2.3-pre.1,and so on.
@jameschensmith, if you would be so kind as to give this a look over, and make sure it fixes the bug you found, I would greatly appreciate it. Thanks!
References
Related to #374, #375 (includes the patch from #375).