Skip to content

Commit fc0e27d

Browse files
Merge pull request #2747 from scala-steward-org/feature/grouping
Fix grouping feature
2 parents f90f842 + 7220ff9 commit fc0e27d

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ final class NurtureAlg[F[_]](config: VCSCfg)(implicit
162162
data.update
163163
.on(
164164
update = editAlg.applyUpdate(data.repoData, _, createBranch),
165-
grouped = _.updates.flatTraverse(editAlg.applyUpdate(data.repoData, _, createBranch))
165+
grouped = createBranch >> _.updates.flatTraverse(editAlg.applyUpdate(data.repoData, _))
166166
)
167167
.flatMap { edits =>
168168
val editCommits = edits.flatMap(_.commits)

modules/core/src/main/scala/org/scalasteward/core/repoconfig/PullRequestsConfig.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ object PullRequestsConfig {
5757
(x, y) =>
5858
PullRequestsConfig(
5959
frequency = x.frequency.orElse(y.frequency),
60+
grouping = x.grouping |+| y.grouping,
6061
includeMatchedLabels = x.includeMatchedLabels.orElse(y.includeMatchedLabels)
6162
)
6263
)

modules/core/src/main/scala/org/scalasteward/core/util/logger.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ object logger {
6969
}
7070

7171
def showUpdates(allUpdates: List[AnUpdate]): String = {
72-
val updates = allUpdates.flatMap {
73-
case g: GroupedUpdate => g.updates.map(_.show)
74-
case u: Update => List(u.show)
72+
val updates = allUpdates.map {
73+
case g: GroupedUpdate =>
74+
g.updates.map(_.show).mkString(s"${g.name} (group) {\n ", "\n ", "\n }")
75+
case u: Update => u.show
7576
}
7677

7778
val list = string.indentLines(updates)

modules/core/src/test/scala/org/scalasteward/core/util/loggerTest.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import org.scalasteward.core.mock.MockContext.context._
55
import org.scalasteward.core.mock.MockState.TraceEntry.Log
66
import org.scalasteward.core.mock.{MockEff, MockState}
77
import org.scalasteward.core.util.logger.LoggerOps
8+
import org.scalasteward.core.util.logger.showUpdates
9+
import org.scalasteward.core.TestSyntax._
10+
import org.scalasteward.core.data.GroupedUpdate
811

912
class loggerTest extends CatsEffectSuite {
1013
test("attemptError.label_") {
@@ -26,4 +29,37 @@ class loggerTest extends CatsEffectSuite {
2629
assertEquals(state.trace.size, 1)
2730
}
2831
}
32+
33+
test("showUpdates") {
34+
val a = ("a".g % "a".a % "1.0.0" %> "1.0.1").single
35+
val b = ("a".g % "b".a % "1.0.0" %> "1.1.0").single
36+
val c = ("a".g % "c".a % "1.0.0" %> "2.0.0").single
37+
38+
val list = List(
39+
GroupedUpdate("all", None, List(a, b, c)),
40+
GroupedUpdate("some", None, List(a, b)),
41+
a,
42+
b,
43+
c
44+
)
45+
46+
val result = showUpdates(list)
47+
48+
val expected = """Found 5 updates:
49+
| all (group) {
50+
| a:a : 1.0.0 -> 1.0.1
51+
| a:b : 1.0.0 -> 1.1.0
52+
| a:c : 1.0.0 -> 2.0.0
53+
| }
54+
| some (group) {
55+
| a:a : 1.0.0 -> 1.0.1
56+
| a:b : 1.0.0 -> 1.1.0
57+
| }
58+
| a:a : 1.0.0 -> 1.0.1
59+
| a:b : 1.0.0 -> 1.1.0
60+
| a:c : 1.0.0 -> 2.0.0""".stripMargin
61+
62+
assertEquals(result, expected)
63+
}
64+
2965
}

0 commit comments

Comments
 (0)