Skip to content

Commit 360a87e

Browse files
committed
feat: prettify PR message body
Include a warning-sign if version:next is a major release, and attempt to structure the PR body with some emojis.
1 parent 684e2f3 commit 360a87e

File tree

3 files changed

+87
-51
lines changed

3 files changed

+87
-51
lines changed

modules/core/src/main/scala/org/scalasteward/core/forge/data/NewPullRequestData.scala

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,24 @@ object NewPullRequestData {
6666

6767
val updateInfoUrls = artifactIdToUpdateInfoUrls.getOrElse(u.mainArtifactId, Nil)
6868

69-
s"""|Updates $artifacts ${fromTo(u)}.
70-
|${renderUpdateInfoUrls(updateInfoUrls).getOrElse("")}""".stripMargin.trim
69+
s"""|## Update _${artifacts}_
70+
|:package: updates $artifacts ${fromTo(u)}${showMajorUpgradeWarning(u)}
71+
|${renderUpdateInfoUrls(updateInfoUrls)
72+
.map(urls => s":scroll: $urls")
73+
.getOrElse("")}""".stripMargin.trim
7174
},
7275
grouped = g => {
7376
val artifacts = g.updates
7477
.fproduct(u => artifactIdToUpdateInfoUrls.get(u.mainArtifactId).orEmpty)
7578
.map { case (u, updateInfoUrls) =>
76-
s"* ${artifactsWithOptionalUrl(u, artifactIdToUrl)} ${fromTo(u)}" +
77-
renderUpdateInfoUrls(updateInfoUrls).map(urls => s"\n + $urls").getOrElse("")
79+
s"* :package: ${artifactsWithOptionalUrl(u, artifactIdToUrl)} ${fromTo(u)}${showMajorUpgradeWarning(u)}" +
80+
renderUpdateInfoUrls(updateInfoUrls)
81+
.map(urls => s"\n + :scroll: $urls")
82+
.getOrElse("")
7883
}
7984
.mkString_("\n", "\n", "\n")
8085

81-
s"""|Updates:
86+
s"""|## Updates:
8287
|$artifacts""".stripMargin.trim
8388
}
8489
)
@@ -97,11 +102,13 @@ object NewPullRequestData {
97102
|
98103
|Configure Scala Steward for your repository with a [`${RepoConfigAlg.repoConfigBasename}`](${org.scalasteward.core.BuildInfo.gitHubUrl}/blob/${org.scalasteward.core.BuildInfo.gitHeadCommit}/docs/repo-specific-configuration.md) file.
99104
|
100-
|Have a fantastic day writing Scala!
105+
|_Have a fantastic day writing Scala!_
101106
|
102107
|${details.map(_.toHtml).mkString("\n")}
103108
|
109+
|<sup>
104110
|${labels.mkString("labels: ", ", ", "")}
111+
|</sup>
105112
|""".stripMargin.trim
106113
}
107114

@@ -120,6 +127,17 @@ object NewPullRequestData {
120127
def fromTo(update: Update.Single): String =
121128
s"from ${update.currentVersion} to ${update.nextVersion}"
122129

130+
def showMajorUpgradeWarning(u: Update.Single): String = {
131+
val semVerVersions =
132+
(SemVer.parse(u.currentVersion.value), SemVer.parse(u.nextVersion.value)).tupled
133+
val semVerLabel = semVerVersions.flatMap { case (curr, next) =>
134+
SemVer.getChangeEarly(curr, next).map(c => c.render)
135+
}
136+
if (semVerLabel == Some("major"))
137+
s" :warning:"
138+
else s""
139+
}
140+
123141
def artifactsWithOptionalUrl(update: Update.Single, artifactIdToUrl: Map[String, Uri]): String =
124142
update match {
125143
case s: Update.ForArtifactId =>
@@ -150,7 +168,7 @@ object NewPullRequestData {
150168
)
151169

152170
Details(
153-
s"Files still referring to the old version $number",
171+
s":mag: Files still referring to the old version $number",
154172
s"""The following files still refer to the old version $numberWithVersion.
155173
|You might want to review and update them manually.
156174
|```
@@ -161,7 +179,7 @@ object NewPullRequestData {
161179
}
162180

163181
def adjustFutureUpdates(update: Update): Details = Details(
164-
"Adjust future updates",
182+
":wrench: Adjust future updates",
165183
update.on(
166184
update = u =>
167185
s"""|Add this to your `${RepoConfigAlg.repoConfigBasename}` file to ignore future updates of this dependency:
@@ -188,7 +206,7 @@ object NewPullRequestData {
188206

189207
def configParsingErrorDetails(error: String): Details =
190208
Details(
191-
s"Note that the Scala Steward config file `${RepoConfigAlg.repoConfigBasename}` wasn't parsed correctly",
209+
s":warning: Note that the Scala Steward config file `${RepoConfigAlg.repoConfigBasename}` wasn't parsed correctly",
192210
s"""|```
193211
|$error
194212
|```
@@ -213,7 +231,7 @@ object NewPullRequestData {
213231
s"* $name$createdChange\n$listElements"
214232
}
215233
.mkString("\n")
216-
Details("Applied Scalafix Migrations", body)
234+
Details(":bulb: Applied Scalafix Migrations", body)
217235
}
218236

219237
def from(

modules/core/src/test/scala/org/scalasteward/core/forge/data/NewPullRequestDataTest.scala

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class NewPullRequestDataTest extends FunSuite {
2828
labels = List("library-update")
2929
)
3030
val expected =
31-
s"""|Updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3.
31+
s"""|## Update _ch.qos.logback:logback-classic_
32+
|:package: updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
3233
|
3334
|
3435
|I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
@@ -37,10 +38,10 @@ class NewPullRequestDataTest extends FunSuite {
3738
|
3839
|Configure Scala Steward for your repository with a [`.scala-steward.conf`](https://github.com/scala-steward-org/scala-steward/blob/${org.scalasteward.core.BuildInfo.gitHeadCommit}/docs/repo-specific-configuration.md) file.
3940
|
40-
|Have a fantastic day writing Scala!
41+
|_Have a fantastic day writing Scala!_
4142
|
4243
|<details>
43-
|<summary>Adjust future updates</summary>
44+
|<summary>:wrench: Adjust future updates</summary>
4445
|
4546
|Add this to your `.scala-steward.conf` file to ignore future updates of this dependency:
4647
|```
@@ -55,7 +56,9 @@ class NewPullRequestDataTest extends FunSuite {
5556
|```
5657
|</details>
5758
|
58-
|labels: library-update""".stripMargin
59+
|<sup>
60+
|labels: library-update
61+
|</sup>""".stripMargin
5962

6063
assertEquals(body, expected)
6164
}
@@ -83,7 +86,8 @@ class NewPullRequestDataTest extends FunSuite {
8386
labels = List("library-update")
8487
)
8588
val expected =
86-
s"""|Updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3.
89+
s"""|## Update _ch.qos.logback:logback-classic_
90+
|:package: updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
8791
|
8892
|
8993
|I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
@@ -92,16 +96,16 @@ class NewPullRequestDataTest extends FunSuite {
9296
|
9397
|Configure Scala Steward for your repository with a [`.scala-steward.conf`](https://github.com/scala-steward-org/scala-steward/blob/${org.scalasteward.core.BuildInfo.gitHeadCommit}/docs/repo-specific-configuration.md) file.
9498
|
95-
|Have a fantastic day writing Scala!
99+
|_Have a fantastic day writing Scala!_
96100
|
97101
|<details>
98-
|<summary>Applied Scalafix Migrations</summary>
102+
|<summary>:bulb: Applied Scalafix Migrations</summary>
99103
|
100104
|* com.spotify:scio-core:0.7.0
101105
| * I am a rewrite rule
102106
|</details>
103107
|<details>
104-
|<summary>Adjust future updates</summary>
108+
|<summary>:wrench: Adjust future updates</summary>
105109
|
106110
|Add this to your `.scala-steward.conf` file to ignore future updates of this dependency:
107111
|```
@@ -116,7 +120,9 @@ class NewPullRequestDataTest extends FunSuite {
116120
|```
117121
|</details>
118122
|
119-
|labels: library-update""".stripMargin
123+
|<sup>
124+
|labels: library-update
125+
|</sup>""".stripMargin
120126

121127
assertEquals(body, expected)
122128
}
@@ -136,10 +142,10 @@ class NewPullRequestDataTest extends FunSuite {
136142
labels = List("library-update")
137143
)
138144
val expected =
139-
s"""|Updates:
145+
s"""|## Updates:
140146
|
141-
|* ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
142-
|* com.example:foo from 1.0.0 to 2.0.0
147+
|* :package: ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
148+
|* :package: com.example:foo from 1.0.0 to 2.0.0 :warning:
143149
|
144150
|
145151
|I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
@@ -148,10 +154,10 @@ class NewPullRequestDataTest extends FunSuite {
148154
|
149155
|Configure Scala Steward for your repository with a [`.scala-steward.conf`](https://github.com/scala-steward-org/scala-steward/blob/${org.scalasteward.core.BuildInfo.gitHeadCommit}/docs/repo-specific-configuration.md) file.
150156
|
151-
|Have a fantastic day writing Scala!
157+
|_Have a fantastic day writing Scala!_
152158
|
153159
|<details>
154-
|<summary>Adjust future updates</summary>
160+
|<summary>:wrench: Adjust future updates</summary>
155161
|
156162
|Add these to your `.scala-steward.conf` file to ignore future updates of these dependencies:
157163
|```
@@ -175,7 +181,9 @@ class NewPullRequestDataTest extends FunSuite {
175181
|```
176182
|</details>
177183
|
178-
|labels: library-update""".stripMargin
184+
|<sup>
185+
|labels: library-update
186+
|</sup>""".stripMargin
179187

180188
assertEquals(body, expected)
181189
}
@@ -193,7 +201,8 @@ class NewPullRequestDataTest extends FunSuite {
193201
labels = List("library-update")
194202
)
195203
val expected =
196-
s"""|Updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3.
204+
s"""|## Update _ch.qos.logback:logback-classic_
205+
|:package: updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
197206
|
198207
|
199208
|I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
@@ -202,10 +211,10 @@ class NewPullRequestDataTest extends FunSuite {
202211
|
203212
|Configure Scala Steward for your repository with a [`.scala-steward.conf`](https://github.com/scala-steward-org/scala-steward/blob/${org.scalasteward.core.BuildInfo.gitHeadCommit}/docs/repo-specific-configuration.md) file.
204213
|
205-
|Have a fantastic day writing Scala!
214+
|_Have a fantastic day writing Scala!_
206215
|
207216
|<details>
208-
|<summary>Adjust future updates</summary>
217+
|<summary>:wrench: Adjust future updates</summary>
209218
|
210219
|Add this to your `.scala-steward.conf` file to ignore future updates of this dependency:
211220
|```
@@ -220,14 +229,16 @@ class NewPullRequestDataTest extends FunSuite {
220229
|```
221230
|</details>
222231
|<details>
223-
|<summary>Note that the Scala Steward config file `.scala-steward.conf` wasn't parsed correctly</summary>
232+
|<summary>:warning: Note that the Scala Steward config file `.scala-steward.conf` wasn't parsed correctly</summary>
224233
|
225234
|```
226235
|parsing error
227236
|```
228237
|</details>
229238
|
230-
|labels: library-update""".stripMargin
239+
|<sup>
240+
|labels: library-update
241+
|</sup>""".stripMargin
231242

232243
assertEquals(body, expected)
233244
}
@@ -311,7 +322,7 @@ class NewPullRequestDataTest extends FunSuite {
311322
assertEquals(
312323
appliedMigrations.fold("")(_.toHtml),
313324
"""<details>
314-
|<summary>Applied Scalafix Migrations</summary>
325+
|<summary>:bulb: Applied Scalafix Migrations</summary>
315326
|
316327
|* com.spotify:scio-core:0.7.0
317328
| * I am a rewrite rule
@@ -341,7 +352,7 @@ class NewPullRequestDataTest extends FunSuite {
341352
assertEquals(
342353
detail.fold("")(_.toHtml),
343354
"""<details>
344-
|<summary>Applied Scalafix Migrations</summary>
355+
|<summary>:bulb: Applied Scalafix Migrations</summary>
345356
|
346357
|* com.spotify:scio-core:0.7.0
347358
| * I am a rewrite rule
@@ -383,7 +394,7 @@ class NewPullRequestDataTest extends FunSuite {
383394
assertEquals(
384395
detail.fold("")(_.toHtml),
385396
"""<details>
386-
|<summary>Applied Scalafix Migrations</summary>
397+
|<summary>:bulb: Applied Scalafix Migrations</summary>
387398
|
388399
|* com.spotify:scio-core:0.7.0
389400
| * I am a rewrite rule
@@ -430,7 +441,7 @@ class NewPullRequestDataTest extends FunSuite {
430441
assertEquals(
431442
note.fold("")(_.toHtml),
432443
"""<details>
433-
|<summary>Files still referring to the old version number</summary>
444+
|<summary>:mag: Files still referring to the old version number</summary>
434445
|
435446
|The following files still refer to the old version number (0.1).
436447
|You might want to review and update them manually.
@@ -506,7 +517,7 @@ class NewPullRequestDataTest extends FunSuite {
506517
assertEquals(
507518
note.fold("")(_.toHtml),
508519
"""<details>
509-
|<summary>Files still referring to the old version numbers</summary>
520+
|<summary>:mag: Files still referring to the old version numbers</summary>
510521
|
511522
|The following files still refer to the old version numbers.
512523
|You might want to review and update them manually.
@@ -529,7 +540,7 @@ class NewPullRequestDataTest extends FunSuite {
529540
assertEquals(
530541
note.toHtml,
531542
"""<details>
532-
|<summary>Adjust future updates</summary>
543+
|<summary>:wrench: Adjust future updates</summary>
533544
|
534545
|Add these to your `.scala-steward.conf` file to ignore future updates of these dependencies:
535546
|```
@@ -576,7 +587,8 @@ class NewPullRequestDataTest extends FunSuite {
576587
)
577588

578589
val expectedBody =
579-
s"""|Updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3.
590+
s"""|## Update _ch.qos.logback:logback-classic_
591+
|:package: updates ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
580592
|
581593
|
582594
|I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
@@ -585,10 +597,10 @@ class NewPullRequestDataTest extends FunSuite {
585597
|
586598
|Configure Scala Steward for your repository with a [`.scala-steward.conf`](https://github.com/scala-steward-org/scala-steward/blob/${org.scalasteward.core.BuildInfo.gitHeadCommit}/docs/repo-specific-configuration.md) file.
587599
|
588-
|Have a fantastic day writing Scala!
600+
|_Have a fantastic day writing Scala!_
589601
|
590602
|<details>
591-
|<summary>Adjust future updates</summary>
603+
|<summary>:wrench: Adjust future updates</summary>
592604
|
593605
|Add this to your `.scala-steward.conf` file to ignore future updates of this dependency:
594606
|```
@@ -603,7 +615,9 @@ class NewPullRequestDataTest extends FunSuite {
603615
|```
604616
|</details>
605617
|
606-
|labels: library-update, early-semver-patch, semver-spec-patch, commit-count:0""".stripMargin
618+
|<sup>
619+
|labels: library-update, early-semver-patch, semver-spec-patch, commit-count:0
620+
|</sup>""".stripMargin
607621

608622
val expected = NewPullRequestData(
609623
title = "Update logback-classic to 1.2.3",
@@ -647,10 +661,10 @@ class NewPullRequestDataTest extends FunSuite {
647661
)
648662

649663
val expectedBody =
650-
s"""|Updates:
664+
s"""|## Updates:
651665
|
652-
|* ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
653-
|* com.example:foo from 1.0.0 to 2.0.0
666+
|* :package: ch.qos.logback:logback-classic from 1.2.0 to 1.2.3
667+
|* :package: com.example:foo from 1.0.0 to 2.0.0 :warning:
654668
|
655669
|
656670
|I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
@@ -659,10 +673,10 @@ class NewPullRequestDataTest extends FunSuite {
659673
|
660674
|Configure Scala Steward for your repository with a [`.scala-steward.conf`](https://github.com/scala-steward-org/scala-steward/blob/${org.scalasteward.core.BuildInfo.gitHeadCommit}/docs/repo-specific-configuration.md) file.
661675
|
662-
|Have a fantastic day writing Scala!
676+
|_Have a fantastic day writing Scala!_
663677
|
664678
|<details>
665-
|<summary>Adjust future updates</summary>
679+
|<summary>:wrench: Adjust future updates</summary>
666680
|
667681
|Add these to your `.scala-steward.conf` file to ignore future updates of these dependencies:
668682
|```
@@ -686,7 +700,9 @@ class NewPullRequestDataTest extends FunSuite {
686700
|```
687701
|</details>
688702
|
689-
|labels: library-update, early-semver-patch, semver-spec-patch, early-semver-major, semver-spec-major, commit-count:0""".stripMargin
703+
|<sup>
704+
|labels: library-update, early-semver-patch, semver-spec-patch, early-semver-major, semver-spec-major, commit-count:0
705+
|</sup>""".stripMargin
690706

691707
val expected = NewPullRequestData(
692708
title = "Update for group my-group",

0 commit comments

Comments
 (0)