Skip to content

Commit

Permalink
Add label for artifact migrations
Browse files Browse the repository at this point in the history
This adds a `artifact-migrations` label for updates where the groupId
and/or artifactId is changed. My main motivation for this label is to
search for PRs that rewrite the groupId/artifactId on GitHub and to add
this search to our
[Artifact Migrations documentation](https://github.com/scala-steward-org/scala-steward/blob/main/docs/artifact-migrations.md).
  • Loading branch information
fthomas committed Nov 26, 2023
1 parent 9245385 commit 02ff89d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,18 @@ object NewPullRequestData {
val semverLabels =
update.on(u => semverForUpdate(u), _.updates.flatMap(semverForUpdate(_)).distinct)

val artifactMigrationsLabel = Option.when {
update.asSingleUpdates
.flatMap(_.forArtifactIds.toList)
.exists(u => u.newerGroupId.nonEmpty || u.newerArtifactId.nonEmpty)
}("artifact-migrations")
val scalafixLabel = edits.collectFirst { case _: ScalafixEdit => "scalafix-migrations" }
val oldVersionLabel = Option.when(filesWithOldVersion.nonEmpty)("old-version-remains")

List.concat(
updateTypeLabels(update),
semverLabels,
artifactMigrationsLabel,
scalafixLabel,
oldVersionLabel,
List(commitCountLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class NewPullRequestDataTest extends FunSuite {
assertEquals(body, expected)
}

test("bodyFor() groupped update") {
test("bodyFor() grouped update") {
val update1 = ("ch.qos.logback".g % "logback-classic".a % "1.2.0" %> "1.2.3").single
val update2 = ("com.example".g % "foo".a % "1.0.0" %> "2.0.0").single
val update = Update.Grouped("my-group", Some("The PR title"), List(update1, update2))
Expand Down Expand Up @@ -515,6 +515,13 @@ class NewPullRequestDataTest extends FunSuite {
assertEquals(labels, expected)
}

test("artifact-migrations label") {
val update = ("a".g % "b".a % "1" -> "2").single.copy(newerGroupId = Some("aa".g))
val obtained = labelsFor(update)
val expected = List("library-update", "artifact-migrations", "commit-count:0")
assertEquals(obtained, expected)
}

test("oldVersionNote doesn't show version for grouped updates") {
val files = List("Readme.md", "travis.yml")
val update1 = ("a".g % "b".a % "1" -> "2").single
Expand All @@ -539,7 +546,7 @@ class NewPullRequestDataTest extends FunSuite {
)
}

test("adjustFutureUpdates for grouped udpates shows settings for each update") {
test("adjustFutureUpdates for grouped updates shows settings for each update") {
val update1 = ("a".g % "b".a % "1" -> "2").single
val update2 = ("c".g % "d".a % "1.1.0" % "test" %> "1.2.0").single
val update = Update.Grouped("my-group", None, List(update1, update2))
Expand Down

0 comments on commit 02ff89d

Please sign in to comment.