-
Notifications
You must be signed in to change notification settings - Fork 492
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
Correctly handle prereleases/ANY ranges in subset #377
Correctly handle prereleases/ANY ranges in subset #377
Conversation
Adds short-circuit check if superset is `*`. PR-URL: #375 Credit: @jameschensmith Close: #375 Reviewed-by: @isaacs
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | ||
// - 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be the following (could be wrong):
// - If GT.semver has a prerelease, and not in prerelease mode | |
// - If LT.semver has a prerelease, and not in prerelease mode |
@@ -15,6 +15,29 @@ const cases = [ | |||
['>2 <1', '3', true], | |||
['1 || 2 || 3', '>=1.0.0', true], | |||
|
|||
// everything is a subset of * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should probably say something new, since this is not always true 😅
An "ANY" range (ie,
""
,*
, etc.) does not include prereleaseversions 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 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).