Skip to content

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