Skip to content

Commit ead762a

Browse files
committed
Short-circuit when reading mill-version files
If a `.mill-version` exists there is no need to also read `.config/mill-version` and then discard its content.
1 parent 26f9dd0 commit ead762a

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

modules/core/src/main/scala/org/scalasteward/core/buildtool/mill/MillAlg.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,10 @@ final class MillAlg[F[_]](defaultResolver: Resolver)(implicit
9292
Some("https://github.com/scala-steward-org/scala-steward/issues/2838")
9393

9494
private def getMillVersion(buildRootDir: File): F[Option[Version]] =
95-
for {
96-
millVersionFileContent <- fileAlg.readFile(buildRootDir / s".$millVersionName")
97-
millVersionFileInConfigContent <- fileAlg.readFile(buildRootDir / ".config" / millVersionName)
98-
version = millVersionFileContent
99-
.orElse(millVersionFileInConfigContent)
100-
.flatMap(parser.parseMillVersion)
101-
} yield version
95+
List(
96+
buildRootDir / s".$millVersionName",
97+
buildRootDir / ".config" / millVersionName
98+
).collectFirstSomeM(fileAlg.readFile).map(_.flatMap(parser.parseMillVersion))
10299

103100
private def getMillPluginDeps(
104101
millVersion: Version,

modules/core/src/test/scala/org/scalasteward/core/buildtool/mill/MillAlgTest.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class MillAlgTest extends FunSuite {
5757
val expected = initial.copy(
5858
trace = Vector(
5959
Cmd("read", s"$repoDir/.mill-version"),
60-
Cmd("read", s"$repoDir/.config/mill-version"),
6160
millCmd,
6261
Cmd("read", s"$repoDir/build.sc")
6362
)

0 commit comments

Comments
 (0)