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: Implement MinVersion() for Constraints. #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taeold
Copy link

@taeold taeold commented Dec 16, 2023

MinVersion() returns return the lowest version that can possibly match the given constraint.

For examples:

  • MinVersion("1.0.1") = "1.0.1"
  • MinVersion("=1.0.1") = "1.0.1"
  • MinVersion("~1.0.1") = "1.0.1"
  • MinVersion(">1.0.1") = "1.0.2"
  • MinVersion(">=1.0.1") = "1.0.1"
  • MinVersion("<2.0.0 >1.0.1") = "1.0.2"

etc.

The implementation is based on node-semver:

https://github.com/npm/node-semver/blob/main/ranges/min-version.js

One minor difference is how prerelease versions are treated given >:

  • In node-semver, MinVersion(">1.0.0-beta') = "1.0.0-beta.0"
  • In the proposed impl, MinVersion(">1.0.0-beta') = "1.0.0"

This behavior made more sense to me given how Version("1.0.0-beta").IncPatch() behaves.

MinVersion() returns return the lowest version that can possibly match the given constraint.

For examples:

  *  `MinVersion("1.0.1") = "1.0.1"`
  *  `MinVersion("=1.0.1") = "1.0.1"`
  *  `MinVersion("~1.0.1") = "1.0.1"`
  *  `MinVersion(">1.0.1") = "1.0.2"`
  *  `MinVersion(">=1.0.1") = "1.0.1"`
  *  `MinVersion("<2.0.0 >1.0.1") = "1.0.2"`

etc.

The implementation is based on node-semver:

  https://github.com/npm/node-semver/blob/main/ranges/min-version.js

One minor difference is how prerelease versions are treated given `>`:

  * In node-semver, `MinVersion(">1.0.0-beta') = "1.0.0-beta.0"`
  * In the proposed impl, `MinVersion(">1.0.0-beta') = "1.0.0"`

This behavior made more sense to me given how Version("1.0.0-beta").IncPatch() behaves.
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.

1 participant