Repository: scala-steward-org/scala-steward (scala)

Issue:
`scala-cli` dependencies: "WARN  Unable to bump version for update [...]"
Hi all! I'm facing some issues with a Scala CLI repository: my private Scala Steward runner is not updating the project's dependencies after properly recognizing they need to get bumped.

Scala Steward logs when processing:

```
  2024-06-01 22:37:57,270 INFO  Found 7 updates:
    com.softwaremill.sttp.client3:(cats, cats_3) : 3.9.6 -> 3.9.7
    com.softwaremill.sttp.client3:(cats, cats_3) : 3.9.6 -> 3.9.7
    com.softwaremill.sttp.client3:(circe, circe_3) : 3.9.6 -> 3.9.7
    com.softwaremill.sttp.client3:(circe, circe_3) : 3.9.6 -> 3.9.7
    com.softwaremill.sttp.client3:(core, core_3) : 3.9.6 -> 3.9.7
    com.softwaremill.sttp.client3:(core, core_3) : 3.9.6 -> 3.9.7
    org.scalameta:(munit, munit_3) : 0.7.29 -> 1.0.0
  2024-06-01 22:37:57,274 INFO  horothesun/my-repo is outdated:
    new version: com.softwaremill.sttp.client3:(cats, cats_3) : 3.9.6 -> 3.9.7
    new version: com.softwaremill.sttp.client3:(circe, circe_3) : 3.9.6 -> 3.9.7
    new version: com.softwaremill.sttp.client3:(core, core_3) : 3.9.6 -> 3.9.7
    new version: org.scalameta:(munit, munit_3) : 0.7.29 -> 1.0.0
  2024-06-01 22:37:57,275 INFO  Nurture horothesun/my-repo
  2024-06-01 22:37:57,282 INFO  Clone horothesun/my-repo
  2024-06-01 22:37:57,845 INFO  Found 2 updates:
    com.softwaremill.sttp.client3:{(cats, cats_3), (circe, circe_3), (core, core_3)} : 3.9.6 -> 3.9.7
    org.scalameta:(munit, munit_3) : 0.7.29 -> 1.0.0
  2024-06-01 22:37:57,862 INFO  Process update com.softwaremill.sttp.client3:{(cats, cats_3), (circe, circe_3), (core, core_3)} : 3.9.6 -> 3.9.7
  2024-06-01 22:37:58,089 WARN  Unable to bump version for update com.softwaremill.sttp.client3:{(cats, cats_3), (circe, circe_3), (core, core_3)} : 3.9.6 -> 3.9.7
  2024-06-01 22:37:58,091 WARN  No commits created
  2024-06-01 22:37:58,104 INFO  Process update org.scalameta:(munit, munit_3) : 0.7.29 -> 1.0.0
  2024-06-01 22:37:58,256 WARN  Unable to bump version for update org.scalameta:(munit, munit_3) : 0.7.29 -> 1.0.0
  2024-06-01 22:37:58,256 WARN  No commits created
```

Here're the `main.sc` dependencies section:

```scala
//> using scala "3.4.2"
//> using jvm "temurin:21"

//> using dep "org.typelevel::cats-effect:3.5.4"
//> using dep "co.fs2::fs2-core:3.10.2"
//> using dep "com.softwaremill.sttp.client3::core:3.9.6"
//> using dep "com.softwaremill.sttp.client3::cats:3.9.6"
//> using dep "com.softwaremill.sttp.client3::circe:3.9.6"
//> using dep "io.circe::circe-core:0.14.7"
//> using dep "io.circe::circe-generic:0.14.7"

//> using test.dep "org.scalameta::munit:0.7.29"
```

P.S.: the Scala version (`3.4.2`) was updated correctly by the Scala Steward runner, though.

TIA! 🙏

Pull request description:
Fixes https://github.com/scala-steward-org/scala-steward/issues/3371.

I tested these changes on the same `scala-cli`-based repository I was having issues with and the correct PRs got created.

Patch:
diff --git a/README.md b/README.md
index e0d5816a5d..a71c69bbbf 100644
--- a/README.md
+++ b/README.md
@@ -140,6 +140,7 @@ Thanks goes to these wonderful people for contributing to Scala Steward:
 * [miguelpuyol](https://github.com/miguelpuyol)
 * [nafg](https://github.com/nafg)
 * [Nabil Abdel-Hafeez](https://github.com/987Nabil)
+* [Nicola Di Pol](https://github.com/horothesun)
 * [Ondra Pelech](https://github.com/sideeffffect)
 * [Pavel Shapkin](https://github.com/psttf)
 * [Philippus Baalman](https://github.com/Philippus)
diff --git a/modules/core/src/main/scala/org/scalasteward/core/edit/update/Selector.scala b/modules/core/src/main/scala/org/scalasteward/core/edit/update/Selector.scala
index 5800617aaa..7d0390fd15 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/edit/update/Selector.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/edit/update/Selector.scala
@@ -70,9 +70,13 @@ object Selector {
     versionPositions
       .collect { case p: DependencyDef => p }
       .filter {
-        case p: MillDependency => scalaCliUsingLib.matcher(p.before).matches() || !p.isCommented
-        case p: SbtDependency  => !p.isCommented && !p.before.toLowerCase.contains("previous")
-        case _                 => true
+        case p: MillDependency =>
+          scalaCliUsingLib.matcher(p.before).matches() ||
+          scalaCliUsingDep.matcher(p.before).matches() ||
+          scalaCliUsingTestDep.matcher(p.before).matches() ||
+          !p.isCommented
+        case p: SbtDependency => !p.isCommented && !p.before.toLowerCase.contains("previous")
+        case _                => true
       }
       .filter { p =>
         val artifactIdNames = Set(p.artifactId, p.artifactId.takeWhile(_ =!= '_'))
@@ -81,9 +85,15 @@ object Selector {
         }
       }
 
-  private def scalaCliUsingLib: Pattern =
+  private val scalaCliUsingLib: Pattern =
     Pattern.compile("""//>\s+using\s+lib\s+""")
 
+  private val scalaCliUsingDep: Pattern =
+    Pattern.compile("""//>\s+using\s+dep\s+""")
+
+  private val scalaCliUsingTestDep: Pattern =
+    Pattern.compile("""//>\s+using\s+test\.dep\s+""")
+
   private def scalaValInDependencyDefPositions(
       versionPositions: List[VersionPosition],
       modulePositions: List[ModulePosition]


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/edit/EditAlgTest.scala b/modules/core/src/test/scala/org/scalasteward/core/edit/EditAlgTest.scala
index fd806bd2fe..60c017e74a 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/edit/EditAlgTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/edit/EditAlgTest.scala
@@ -134,4 +134,155 @@ class EditAlgTest extends FunSuite {
       case Log(_) => false
     })
   }
+
+  test("applyUpdate for scala-cli using lib") {
+    val repo = Repo("edit-alg", "test-4")
+    val data = RepoData(repo, dummyRepoCache, RepoConfig.empty)
+    val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync()
+    val mainSc = repoDir / "main.sc"
+    val update = ("org.typelevel".g % "cats-effect".a % "3.5.2" %> "3.5.4").single
+
+    val state = MockState.empty
+      .copy(execCommands = true)
+      .initGitRepo(
+        repoDir,
+        mainSc ->
+          """
+            |//> using scala "3.4.2"
+            |//> using jvm "temurin:21"
+            |//> using lib "org.typelevel::cats-effect:3.5.2"
+            |println("Hello!")
+            |""".stripMargin
+      )
+      .flatMap(editAlg.applyUpdate(data, update).runS)
+      .unsafeRunSync()
+
+    val expected = MockState.empty.copy(
+      execCommands = true,
+      trace = Vector(
+        Cmd.gitGrep(repoDir, update.currentVersion.value),
+        Cmd("read", mainSc.pathAsString),
+        Cmd.gitGrep(repoDir, update.groupId.value),
+        Cmd("read", mainSc.pathAsString),
+        Cmd("read", mainSc.pathAsString),
+        Cmd("write", mainSc.pathAsString),
+        Cmd.gitStatus(repoDir),
+        Cmd.gitCommit(repoDir, "Update cats-effect to 3.5.4"),
+        Cmd.gitLatestSha1(repoDir)
+      ),
+      files = Map(
+        mainSc ->
+          """
+            |//> using scala "3.4.2"
+            |//> using jvm "temurin:21"
+            |//> using lib "org.typelevel::cats-effect:3.5.4"
+            |println("Hello!")
+            |""".stripMargin
+      )
+    )
+
+    assertEquals(state, expected)
+  }
+
+  test("applyUpdate for scala-cli using dep") {
+    val repo = Repo("edit-alg", "test-5")
+    val data = RepoData(repo, dummyRepoCache, RepoConfig.empty)
+    val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync()
+    val mainSc = repoDir / "main.sc"
+    val update = ("org.typelevel".g % "cats-effect".a % "3.5.2" %> "3.5.4").single
+
+    val state = MockState.empty
+      .copy(execCommands = true)
+      .initGitRepo(
+        repoDir,
+        mainSc ->
+          """
+            |//> using scala "3.4.2"
+            |//> using jvm "temurin:21"
+            |//> using dep "org.typelevel::cats-effect:3.5.2"
+            |//> using test.dep "org.scalameta::munit:1.0.0"
+            |println("Hello!")
+            |""".stripMargin
+      )
+      .flatMap(editAlg.applyUpdate(data, update).runS)
+      .unsafeRunSync()
+
+    val expected = MockState.empty.copy(
+      execCommands = true,
+      trace = Vector(
+        Cmd.gitGrep(repoDir, update.currentVersion.value),
+        Cmd("read", mainSc.pathAsString),
+        Cmd.gitGrep(repoDir, update.groupId.value),
+        Cmd("read", mainSc.pathAsString),
+        Cmd("read", mainSc.pathAsString),
+        Cmd("write", mainSc.pathAsString),
+        Cmd.gitStatus(repoDir),
+        Cmd.gitCommit(repoDir, "Update cats-effect to 3.5.4"),
+        Cmd.gitLatestSha1(repoDir)
+      ),
+      files = Map(
+        mainSc ->
+          """
+            |//> using scala "3.4.2"
+            |//> using jvm "temurin:21"
+            |//> using dep "org.typelevel::cats-effect:3.5.4"
+            |//> using test.dep "org.scalameta::munit:1.0.0"
+            |println("Hello!")
+            |""".stripMargin
+      )
+    )
+
+    assertEquals(state, expected)
+  }
+
+  test("applyUpdate for scala-cli using test.dep") {
+    val repo = Repo("edit-alg", "test-6")
+    val data = RepoData(repo, dummyRepoCache, RepoConfig.empty)
+    val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync()
+    val mainSc = repoDir / "main.sc"
+    val update = ("org.scalameta".g % "munit".a % "0.7.29" %> "1.0.0").single
+
+    val state = MockState.empty
+      .copy(execCommands = true)
+      .initGitRepo(
+        repoDir,
+        mainSc ->
+          """
+            |//> using scala "3.4.2"
+            |//> using jvm "temurin:21"
+            |//> using dep "org.typelevel::cats-effect:3.5.4"
+            |//> using test.dep "org.scalameta::munit:0.7.29"
+            |println("Hello!")
+            |""".stripMargin
+      )
+      .flatMap(editAlg.applyUpdate(data, update).runS)
+      .unsafeRunSync()
+
+    val expected = MockState.empty.copy(
+      execCommands = true,
+      trace = Vector(
+        Cmd.gitGrep(repoDir, update.currentVersion.value),
+        Cmd("read", mainSc.pathAsString),
+        Cmd.gitGrep(repoDir, update.groupId.value),
+        Cmd("read", mainSc.pathAsString),
+        Cmd("read", mainSc.pathAsString),
+        Cmd("write", mainSc.pathAsString),
+        Cmd.gitStatus(repoDir),
+        Cmd.gitCommit(repoDir, "Update munit to 1.0.0"),
+        Cmd.gitLatestSha1(repoDir)
+      ),
+      files = Map(
+        mainSc ->
+          """
+            |//> using scala "3.4.2"
+            |//> using jvm "temurin:21"
+            |//> using dep "org.typelevel::cats-effect:3.5.4"
+            |//> using test.dep "org.scalameta::munit:1.0.0"
+            |println("Hello!")
+            |""".stripMargin
+      )
+    )
+
+    assertEquals(state, expected)
+  }
 }