Change semantics to match previous semantics

We're unsure about SemVer's semantics around pre-releases, so for now we
just revert this refactoring to preserve the semantics it's always had.
This commit is contained in:
Dale Wijnand 2018-04-05 14:36:35 +01:00
parent 79e31a3e0f
commit f74ec06699
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
2 changed files with 9 additions and 4 deletions

View File

@ -129,6 +129,9 @@ object VersionNumber {
* Rule 2 we enforce with custom extractors.
* Rule 4 we enforce by matching x = 0 & fully equals checking the two versions
* Rule 6, 7 & 8 means version compatibility is determined by comparing the two X values
* Rule 9..
* Dale thinks means pre-release versions are fully equals checked..
* Eugene thinks means pre-releases before 1.0.0 are not compatible, if not they are..
*/
def isCompatible(v1: VersionNumber, v2: VersionNumber): Boolean =
doIsCompat(dropBuildMetadata(v1), dropBuildMetadata(v2))
@ -136,6 +139,7 @@ object VersionNumber {
private[this] def doIsCompat(v1: VersionNumber, v2: VersionNumber): Boolean =
(v1, v2) match {
case (NormalVersion(0, _, _), NormalVersion(0, _, _)) => v1 == v2 // R4
case (NormalVersion(_, 0, 0), NormalVersion(_, 0, 0)) => v1 == v2 // R9 maybe?
case (NormalVersion(x1, _, _), NormalVersion(x2, _, _)) => x1 == x2 // R6, R7 & R8
case _ => false
}
@ -168,6 +172,7 @@ object VersionNumber {
private[this] def doIsCompat(v1: VersionNumber, v2: VersionNumber): Boolean = {
(v1, v2) match {
case (NormalVersion(_, _, 0), NormalVersion(_, _, 0)) => v1 == v2 // R9 maybe?
case (NormalVersion(x1, y1, _), NormalVersion(x2, y2, _)) => (x1 == x2) && (y1 == y2)
case _ => false
}

View File

@ -26,12 +26,12 @@ class VersionNumberSpec extends FreeSpec with Matchers with Inside {
assertIsCompatibleWith(v, "1.0.1", SemVer)
assertIsCompatibleWith(v, "1.1.1", SemVer)
assertIsNotCompatibleWith(v, "2.0.0", SemVer)
assertIsCompatibleWith(v, "1.0.0-M1", SemVer)
assertIsNotCompatibleWith(v, "1.0.0-M1", SemVer)
assertIsCompatibleWith(v, "1.0.1", SecondSegment)
assertIsNotCompatibleWith(v, "1.1.1", SecondSegment)
assertIsNotCompatibleWith(v, "2.0.0", SecondSegment)
assertIsCompatibleWith(v, "1.0.0-M1", SecondSegment)
assertIsNotCompatibleWith(v, "1.0.0-M1", SecondSegment)
}
version("1.0.0.0") { v =>
@ -49,7 +49,7 @@ class VersionNumberSpec extends FreeSpec with Matchers with Inside {
assertIsNotCompatibleWith(v, "0.12.1", SemVer)
assertIsNotCompatibleWith(v, "0.12.1-M1", SemVer)
assertIsCompatibleWith(v, "0.12.0-RC1", SecondSegment)
assertIsNotCompatibleWith(v, "0.12.0-RC1", SecondSegment)
assertIsCompatibleWith(v, "0.12.1", SecondSegment)
assertIsCompatibleWith(v, "0.12.1-M1", SecondSegment)
}
@ -63,7 +63,7 @@ class VersionNumberSpec extends FreeSpec with Matchers with Inside {
assertIsCompatibleWith(v, "0.1.0-SNAPSHOT+001", SemVer)
assertIsCompatibleWith(v, "0.1.0-SNAPSHOT", SecondSegment)
assertIsCompatibleWith(v, "0.1.0", SecondSegment)
assertIsNotCompatibleWith(v, "0.1.0", SecondSegment)
assertIsCompatibleWith(v, "0.1.0-SNAPSHOT+001", SecondSegment)
}