Skip to content

Commit

Permalink
For -S 3.x input use latest release from 3.x versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Jan 20, 2022
1 parent bcbc867 commit 7a81cc6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,17 @@ final case class BuildOptions(
sv match {
case Some(sv0) =>
val prefix = if (sv0.endsWith(".")) sv0 else sv0 + "."
val matchingVersions = allVersions.filter(_.startsWith(prefix))
val matchingVersions = allVersions.filter(_.startsWith(prefix)).map(Version(_))
if (matchingVersions.isEmpty)
Left(new InvalidBinaryScalaVersionError(sv0))
else {
val validMaxVersions = maxSupportedScalaVersions
.filter(_.repr.startsWith(prefix))
val validMatchingVersions = matchingVersions
.map(Version(_))
.filter(v => validMaxVersions.exists(v <= _))
val validMatchingVersions =
if (prefix.startsWith("3.") && prefix.length > 2) matchingVersions
else
matchingVersions
.filter(v => validMaxVersions.exists(v <= _))
if (validMatchingVersions.isEmpty)
Left(new UnsupportedScalaVersionError(sv0))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class BuildOptionsTests extends munit.FunSuite {
Some("2.12") -> defaultScala212Version,
Some("2") -> defaultScala213Version,
Some("2.13.2") -> "2.13.2",
Some("3.0.1") -> "3.0.1"
Some("3.0.1") -> "3.0.1",
Some("3.0") -> "3.0.2"
)

for ((prefix, expectedScalaVersion) <- expectedScalaVersions)
Expand All @@ -61,6 +62,7 @@ class BuildOptionsTests extends munit.FunSuite {

val expectedScalaConfVersions = Seq(
Some("3") -> "3.0.1",
Some("3.0") -> "3.0.2",
None -> "3.0.1",
Some("2.13") -> "2.13.4",
Some("2.12") -> "2.12.13",
Expand Down

0 comments on commit 7a81cc6

Please sign in to comment.