From 26fa1c5f4bd6a727deb493d9c0f187f168706cfa Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 23 Jul 2017 02:34:36 -0400 Subject: [PATCH] Fixes sbtApiVersion logic The NonRelease pattern matcher is ony checking for the third segment, but for sbt 1.x, we need to check both the second and third segment since 1.1.0-M1 would be bincompat with 1.0. Fixes sbt/sbt#3360 --- .../librarymanagement/cross/CrossVersionUtil.scala | 11 +++++++---- ivy/src/test/scala/CrossVersionTest.scala | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala/sbt/internal/librarymanagement/cross/CrossVersionUtil.scala b/core/src/main/scala/sbt/internal/librarymanagement/cross/CrossVersionUtil.scala index b9d4cc2dd..b9e784a51 100644 --- a/core/src/main/scala/sbt/internal/librarymanagement/cross/CrossVersionUtil.scala +++ b/core/src/main/scala/sbt/internal/librarymanagement/cross/CrossVersionUtil.scala @@ -36,10 +36,13 @@ object CrossVersionUtil { * Compatible versions include 0.12.0-1 and 0.12.0-RC1 for Some(0, 12). */ private[sbt] def sbtApiVersion(v: String): Option[(Long, Long)] = v match { - case ReleaseV(x, y, _, _) => Some(sbtApiVersion(x.toLong, y.toLong)) - case CandidateV(x, y, _, _) => Some(sbtApiVersion(x.toLong, y.toLong)) - case NonReleaseV_n(x, y, z, _) if z.toInt > 0 => Some(sbtApiVersion(x.toLong, y.toLong)) - case _ => None + case ReleaseV(x, y, _, _) => Some(sbtApiVersion(x.toLong, y.toLong)) + case CandidateV(x, y, _, _) => Some(sbtApiVersion(x.toLong, y.toLong)) + case NonReleaseV_n(x, y, z, _) if x.toLong == 0 && z.toLong > 0 => + Some(sbtApiVersion(x.toLong, y.toLong)) + case NonReleaseV_n(x, y, z, _) if x.toLong > 0 && (y.toLong > 0 || z.toLong > 0) => + Some(sbtApiVersion(x.toLong, y.toLong)) + case _ => None } private def sbtApiVersion(x: Long, y: Long) = { diff --git a/ivy/src/test/scala/CrossVersionTest.scala b/ivy/src/test/scala/CrossVersionTest.scala index b2c52a732..5ba8d8b72 100644 --- a/ivy/src/test/scala/CrossVersionTest.scala +++ b/ivy/src/test/scala/CrossVersionTest.scala @@ -135,6 +135,9 @@ class CrossVersionTest extends UnitSpec { it should "for 1.3.0 return 1.0" in { binarySbtVersion("1.3.0") shouldBe "1.0" } + it should "for 1.3.0-SNAPSHOT return 1.0" in { + binarySbtVersion("1.3.0-SNAPSHOT") shouldBe "1.0" + } it should "for 1.10.0 return 1.0" in { binarySbtVersion("1.10.0") shouldBe "1.0" }