Skip to content

Commit be913b9

Browse files
authored
Merge pull request #2884 from alexklibisz/issue-2877-reproduction
Issue #2877: Fix "Unable to bump version" when using a val version in libraryDependencies ++= Seq(...)
2 parents e7d116b + 3cae4b5 commit be913b9

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

modules/core/src/main/scala/org/scalasteward/core/edit/update/data/ModulePosition.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ final case class ModulePosition(
2929
version: Substring.Position
3030
) {
3131
def unwrappedVersion: String =
32-
version.value.dropWhile(Set('"', '$', '{')).reverse.dropWhile(Set('"', '}')).reverse
32+
version.value.dropWhile(Set('"', '$', '{')).reverse.dropWhile(Set('"', '}', ',')).reverse
3333
}

modules/core/src/test/scala/org/scalasteward/core/edit/RewriteTest.scala

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,58 @@ class RewriteTest extends FunSuite {
840840
runApplyUpdate(update, original, expected)
841841
}
842842

843+
test("issue-2877: sbt using same version in a val and a literal using a Seq addition") {
844+
val update = ("org.scalatest".g % Nel.of(
845+
"scalatest".a,
846+
"scalactic".a
847+
) % "3.2.13" %> "3.2.14").group
848+
val original = Map(
849+
"build.sbt" ->
850+
"""
851+
|val ScalaTestVersion = "3.2.13"
852+
|libraryDependencies ++= Seq(
853+
| "org.scalatest" %% "scalatest" % ScalaTestVersion,
854+
| "org.scalatest" %% "scalactic" % "3.2.13"
855+
|)
856+
|""".stripMargin
857+
)
858+
val expected = Map(
859+
"build.sbt" ->
860+
"""
861+
|val ScalaTestVersion = "3.2.14"
862+
|libraryDependencies ++= Seq(
863+
| "org.scalatest" %% "scalatest" % ScalaTestVersion,
864+
| "org.scalatest" %% "scalactic" % "3.2.14"
865+
|)
866+
|""".stripMargin
867+
)
868+
runApplyUpdate(update, original, expected)
869+
}
870+
871+
test("issue-2877: sbt using same version in a val and a literal using individual additions") {
872+
val update = ("org.scalatest".g % Nel.of(
873+
"scalatest".a,
874+
"scalactic".a
875+
) % "3.2.13" %> "3.2.14").group
876+
val original = Map(
877+
"build.sbt" ->
878+
"""
879+
|val ScalaTestVersion = "3.2.13"
880+
|libraryDependencies += "org.scalatest" %% "scalatest" % ScalaTestVersion
881+
|libraryDependencies += "org.scalatest" %% "scalactic" % "3.2.13"
882+
|""".stripMargin
883+
)
884+
val expected = Map(
885+
"build.sbt" ->
886+
"""
887+
|val ScalaTestVersion = "3.2.14"
888+
|libraryDependencies += "org.scalatest" %% "scalatest" % ScalaTestVersion
889+
|libraryDependencies += "org.scalatest" %% "scalactic" % "3.2.14"
890+
|""".stripMargin
891+
)
892+
runApplyUpdate(update, original, expected)
893+
}
894+
843895
private def runApplyUpdate(
844896
update: Update.Single,
845897
files: Map[String, String],

0 commit comments

Comments
 (0)