Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary punctuation before scala-steward:off #1811

Merged
merged 1 commit into from Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,7 +41,7 @@ package object edit {
val buffer = mutable.ListBuffer.empty[(String, Boolean)]
val on = new StringBuilder()
val off = new StringBuilder()
val regexIgnoreMultiLinesBegins = "^\\s*//\\s*scala-steward:off".r
val regexIgnoreMultiLinesBegins = """\s*\p{Punct}+\s*scala-steward:off""".r
def flush(builder: StringBuilder, canReplace: Boolean): Unit =
if (builder.nonEmpty) {
buffer.append((builder.toString(), canReplace))
Expand All @@ -56,7 +56,7 @@ package object edit {
off.append(line)
else if (line.contains("scala-steward:off")) {
flush(on, true)
if (regexIgnoreMultiLinesBegins.findFirstIn(line).isDefined)
if (regexIgnoreMultiLinesBegins.findPrefixOf(line).isDefined)
off.append(line)
else
// single line off
Expand Down
Expand Up @@ -409,6 +409,15 @@ class UpdateHeuristicTest extends AnyFunSuite with Matchers {
).replaceVersionIn(original) shouldBe (Some(expected) -> UpdateHeuristic.moduleId.name)
}

test("hash before `off`") {
val original =
"""# scala-steward:off
|sbt.version=1.2.8
|""".stripMargin
Single("org.scala-sbt" % "sbt" % "1.2.8", Nel.of("1.4.3"))
.replaceVersionIn(original) shouldBe (None -> UpdateHeuristic.all.last.name)
}

test("similar artifactIds and same version") {
val original =
""" "org.typelevel" %%% "cats-core" % "2.0.0-M4",
Expand Down