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

Avoid false positives versionCheck when versionScheme != early-semver #123

Open
bjaglin opened this issue Mar 21, 2022 · 1 comment
Open

Comments

@bjaglin
Copy link

bjaglin commented Mar 21, 2022

/**
* Validates that the given new `version` matches the claimed `compatibility` level.
* @return Some validation error, or None if the version is valid.
*/
def isValidVersion(compatibility: Compatibility, version: String): Boolean = {
val versionNumber = VersionNumber(version)
val major = versionNumber._1
val minor = versionNumber._2
val patch = versionNumber._3
compatibility match {
case Compatibility.None =>
// No compatibility is guaranteed: the major version must be incremented (or the minor version, if major is 0)
if (major.contains(0)) patch.contains(0) // minor version bump
else minor.contains(0) && patch.contains(0) // major version bump
case Compatibility.BinaryCompatible =>
// No source compatibility is guaranteed, the minor version must be incremented (or the patch version, if major is 0)
if (major.contains(0)) true // always OK
else patch.contains(0) // minor version bump
case Compatibility.BinaryAndSourceCompatible =>
// OK, the version can be set to whatever
true
}
}
assumes the module being checked is early-semver as of v2.0.1.

It should either support other versionSchemes or fail if it's not early-semver.

@julienrf
Copy link
Collaborator

Related discussion #60.

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

No branches or pull requests

2 participants