-
Notifications
You must be signed in to change notification settings - Fork 632
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(semver): fix prerelease
handlings in range utils
#4323
Conversation
|
semver/_comparator_intersects.ts
Outdated
* Returns true if the range of possible versions intersects with the other c1arators set of possible versions | ||
* @param c0 The left side c1arator | ||
* @param c1 The right side c1arator | ||
* @returns True if any part of the c1arators intersect |
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.
* Returns true if the range of possible versions intersects with the other c1arators set of possible versions | |
* @param c0 The left side c1arator | |
* @param c1 The right side c1arator | |
* @returns True if any part of the c1arators intersect | |
* Returns true if the range of possible versions intersects with the other comparators set of possible versions | |
* @param c0 The left side comparators | |
* @param c1 The right side comparators | |
* @returns True if any part of the comparators intersect |
I'm not sure why comparators
was changed to c1arators
. Is this deliberate?
semver/range_intersects_test.ts
Outdated
@@ -69,6 +69,7 @@ Deno.test({ | |||
["1.x", "1.3.0 || <1.0.0 >2.0.0", true], | |||
["*", "*", true], | |||
["x", "", true], | |||
["<7.0.0-beta.20", ">7.0.0-beta.0", true], |
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.
Can you please add one or two more tests?
In this PR, |
If there are still use case for So, for example:
An alternative that would maybe make more sense for ranges that do indeed have a max, but is probably less useful because the result would need a flag indicating whether it's inclusive or exclusive, it "the smallest version that is <e; than all the versions that would match this range":
|
Thanks for pointing it. |
prerelease
handlings in range utils
aa2f73d
to
b748e49
Compare
@kt3k Out of curiosity, do these cases behave differently from |
@nicolo-ribaudo These cases try to behave the same as the case when The difference happens when the tested version include We can add option to |
367214f
to
a69689b
Compare
closes #4300
This fixes the case when the given ranges intersect at prerelease versions.
ex.
rangeIntersects(parseRange("<7.0.0-beta.20"), parseRange(">7.0.0-beta.0"))
Current implementation tries to get min/max of comparators and compares them, but
comparatorMax
doesn't work with prerelease versions since it was first introduced in #3385 (It completely ignores prerelease versions)comparatorMax
seems wrong by design because the max of<7.0.0-beta.20
is something like7.0.0-beta.19.zzzz....
(infinite 'z's), and that is very inconvenient to represent in javascript.This PR gives up the current approach for calculating the intersection. Instead this restores the original algorithm used for comparing comparators (see https://github.com/denoland/deno_std/blob/e1698647677d2e58348f3308ddeebb9c40cc0ca9/semver/mod.ts#L821-L874)