-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(versioning): add PVP versioning scheme #32298
base: main
Are you sure you want to change the base?
Conversation
This initial version only supports ranges with form >=X.Y && <V.W Follow up PRs will add support for datasource, manager, and possibly more range forms.
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.
First part
lib/modules/versioning/pvp/index.ts
Outdated
if (versionIntMajor.length === otherIntMajor.length) { | ||
return 'eq'; | ||
} | ||
if (versionIntMajor.length > otherIntMajor.length) { |
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.
So 1.0 > 1
?
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.
Yes, and that's on purpose.
I think equality on a range expression should be defined as it's syntax tree matching (e.g. operators and versions matching). So, if we considered versions 1
and 1.0
equal, ranges >=1.0 && <1.1
and >=1 && <1.1
should also be equal. But we can verify that Cabal does regard a version with an appended .0
as distinct. For example:
$ cabal repl --constraint 'base >=4.18.2.1.0' --with-ghc ghc-9.6.5
[__1] rejecting: base-4.18.2.1/installed-4.18.2.1 (constraint from command line flag requires >=4.18.2.1.0)
$ cabal repl --constraint 'base >=4.18.2.1' --with-ghc ghc-9.6.5
<gives prompt as expected>
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.
Are there any docs which describe this?
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.
Yes. From the PVP spec:
Version number ordering is already defined by Cabal as the lexicographic ordering of the components. For example, 2.0.1 > 1.3.2, and 2.0.1.0 > 2.0.1.
lib/modules/versioning/pvp/index.ts
Outdated
const ver = extractAllComponents(version); | ||
const lower = extractAllComponents(parsed.lower); | ||
const upper = extractAllComponents(parsed.upper); | ||
return ( | ||
'gt' === compareIntArray(upper, ver) && | ||
['eq', 'lt'].includes(compareIntArray(lower, ver)) | ||
); | ||
} |
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 can be replaced with recursions if you support simple ranges
lib/modules/versioning/pvp/index.ts
Outdated
function satisfyingVersion( | ||
versions: string[], | ||
range: string, | ||
onGreaterThan: (isGreaterThan: boolean) => boolean, |
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.
That function parameter could a simply boolean
Thanks for the review, I believe I have addressed your comments. Please let me know if something is missing. |
lib/modules/versioning/pvp/index.ts
Outdated
if (versionIntMajor.length === otherIntMajor.length) { | ||
return 'eq'; | ||
} | ||
if (versionIntMajor.length > otherIntMajor.length) { |
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.
Are there any docs which describe this?
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Changes
This initial version of PVP versioning only supports Cabal ranges with form
Follow up PRs will add support for datasource, manager,
and possibly more range forms.
Context
Documentation (please check one with an [x])
Since these changes are not user facing (yet), I am not editing documentation yet.
How I've tested my work (please select one)
I have verified these changes via:
Since upcoming PRs will add datasource/manager, we can test on real repos then.