Merge pull request #140 from eed3si9n/wip/apifix

Fixes sbtApiVersion logic
This commit is contained in:
Dale Wijnand 2017-07-24 15:21:06 +01:00 committed by GitHub
commit 87f7fcbe51
2 changed files with 10 additions and 4 deletions

View File

@ -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) = {

View File

@ -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"
}