@@ -23,6 +23,7 @@ import org.scalasteward.core.repoconfig.PullRequestGroup
2323import org .scalasteward .core .util
2424import org .scalasteward .core .util .Nel
2525import org .scalasteward .core .coursier .VersionsCache .VersionWithFirstSeen
26+ import org .scalasteward .core .nurture .ApplicableUpdateSet
2627
2728case class ArtifactForUpdate (
2829 crossDependency : CrossDependency ,
@@ -243,12 +244,20 @@ object Update {
243244 groups1.toList.distinct.sortBy(u => u : Update .Single )
244245 }
245246
246- def groupByGroupId (updates : List [ForArtifactId ]): List [Single ] = {
247+ /**
248+ * If a set of ApplicableUpdateSet all have the same GroupId, then they could be a Update.ForGroupId()
249+ *
250+ * If there is only one artifact within a ApplicableUpdateSet for a given group id, just create a
251+ * Update.ForArtifactId
252+ *
253+ * Otherwise, create a Grouped()?
254+ */
255+ def groupByGroupId (updates : List [ApplicableUpdateSet ]): List [Single ] = {
247256 val groups0 =
248- updates.groupByNel(s => (s.groupId , s.versionUpdate ))
249- val groups1 = groups0.map { case ((_, versionUpdate), group) =>
257+ updates.groupByNel(s => (s.commonGroupId , s.commonVersionUpdate ))
258+ val groups1 = groups0.map { case ((Some (_), Some ( versionUpdate) ), group) =>
250259 if (group.tail.isEmpty) group.head
251- else ForGroupId (group.map (_.artifactForUpdate ), versionUpdate.nextVersion)
260+ else ForGroupId (group.flatMap (_.artifactUpdates ), versionUpdate.nextVersion)
252261 }
253262 groups1.toList.distinct.sorted
254263 }
@@ -260,12 +269,12 @@ object Update {
260269 */
261270 def groupByPullRequestGroup (
262271 groups : List [PullRequestGroup ],
263- updates : List [Update . ForArtifactId ]
264- ): (List [Grouped ], List [Update . ForArtifactId ]) =
272+ updates : List [ApplicableUpdateSet ]
273+ ): (List [Grouped ], List [ApplicableUpdateSet ]) =
265274 groups.foldLeft((List .empty[Grouped ], updates)) { case ((grouped, notGrouped), group) =>
266275 notGrouped.partition(group.matches) match {
267276 case (Nil , rest) => (grouped, rest)
268- case (matched, rest) => (grouped :+ Grouped (group.name, group.title, matched), rest)
277+ case (matched, rest) => (grouped :+ Grouped (group.name, group.title, matched.flatMap(_.artifactUpdates) ), rest)
269278 }
270279 }
271280
0 commit comments