Skip to content
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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ysangkok
Copy link
Contributor

@ysangkok ysangkok commented Nov 4, 2024

Changes

This initial version of PVP versioning only supports Cabal ranges with form

>=X.Y && <V.W

Follow up PRs will add support for datasource, manager,
and possibly more range forms.

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

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:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Since upcoming PRs will add datasource/manager, we can test on real repos then.

@secustor secustor self-requested a review November 6, 2024 09:31
Copy link
Collaborator

@secustor secustor left a 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.spec.ts Show resolved Hide resolved
lib/modules/versioning/pvp/readme.md Show resolved Hide resolved
lib/modules/versioning/pvp/index.spec.ts Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/index.ts Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/index.ts Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/index.ts Outdated Show resolved Hide resolved
if (versionIntMajor.length === otherIntMajor.length) {
return 'eq';
}
if (versionIntMajor.length > otherIntMajor.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So 1.0 > 1?

Copy link
Contributor Author

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>

Copy link
Collaborator

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?

Copy link
Contributor Author

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 Show resolved Hide resolved
Comment on lines 102 to 109
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))
);
}
Copy link
Collaborator

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

function satisfyingVersion(
versions: string[],
range: string,
onGreaterThan: (isGreaterThan: boolean) => boolean,
Copy link
Collaborator

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

@ysangkok
Copy link
Contributor Author

ysangkok commented Nov 9, 2024

Thanks for the review, I believe I have addressed your comments. Please let me know if something is missing.

@secustor secustor self-requested a review November 12, 2024 08:04
lib/modules/versioning/pvp/index.spec.ts Show resolved Hide resolved
if (versionIntMajor.length === otherIntMajor.length) {
return 'eq';
}
if (versionIntMajor.length > otherIntMajor.length) {
Copy link
Collaborator

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?

lib/modules/versioning/pvp/readme.md Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/types.ts Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/index.ts Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/index.ts Outdated Show resolved Hide resolved
@rarkins rarkins requested a review from viceice November 20, 2024 12:26
lib/modules/versioning/pvp/range.ts Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/util.ts Outdated Show resolved Hide resolved
lib/modules/versioning/pvp/util.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants