Skip to content

Commit 61a104f

Browse files
committed
Use the name 'UpdatesForGivenEdit' rather than 'ApplicableUpdateSet'
As suggested by Emily: #3852 (comment) ...the most important thing about these sets of updates is that they’re produced by the same edits.
1 parent a87a2eb commit 61a104f

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

modules/core/src/main/scala/org/scalasteward/core/data/Update.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.scalasteward.core.repoconfig.PullRequestGroup
2323
import org.scalasteward.core.util
2424
import org.scalasteward.core.util.Nel
2525
import org.scalasteward.core.coursier.VersionsCache.VersionWithFirstSeen
26-
import org.scalasteward.core.nurture.ApplicableUpdateSet
26+
import org.scalasteward.core.nurture.UpdatesForGivenEdit
2727

2828
case class ArtifactForUpdate(
2929
crossDependency: CrossDependency,
@@ -252,7 +252,7 @@ object Update {
252252
*
253253
* Otherwise, create a Grouped()?
254254
*/
255-
def groupByGroupId(updates: List[ApplicableUpdateSet]): List[Single] = {
255+
def groupByGroupId(updates: List[UpdatesForGivenEdit]): List[Single] = {
256256
val groups0 =
257257
updates.groupByNel(s => (s.commonGroupId, s.commonVersionUpdate))
258258
val groups1 = groups0.map { case ((Some(_), Some(versionUpdate)), group) =>
@@ -269,8 +269,8 @@ object Update {
269269
*/
270270
def groupByPullRequestGroup(
271271
groups: List[PullRequestGroup],
272-
updates: List[ApplicableUpdateSet]
273-
): (List[Grouped], List[ApplicableUpdateSet]) =
272+
updates: List[UpdatesForGivenEdit]
273+
): (List[Grouped], List[UpdatesForGivenEdit]) =
274274
groups.foldLeft((List.empty[Grouped], updates)) { case ((grouped, notGrouped), group) =>
275275
notGrouped.partition(group.matches) match {
276276
case (Nil, rest) => (grouped, rest)

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ import org.scalasteward.core.util.{Nel, UrlChecker}
3636
import org.scalasteward.core.{git, util}
3737
import org.typelevel.log4cats.Logger
3838

39-
case class ApplicableUpdateSet(edits: List[Substring.Replacement], artifactUpdates: List[Update.ForArtifactId]) {
39+
case class UpdatesForGivenEdit(
40+
edits: List[Substring.Replacement],
41+
artifactUpdates: List[Update.ForArtifactId]
42+
) {
4043
val commonGroupId: Option[GroupId] = {
4144
val updatesByGroupId = artifactUpdates.groupBy(_.groupId)
4245
Option.when(updatesByGroupId.size == 1)(updatesByGroupId.keys.head)
@@ -60,17 +63,20 @@ final class NurtureAlg[F[_]](config: ForgeCfg)(implicit
6063
urlChecker: UrlChecker[F],
6164
F: Concurrent[F]
6265
) {
63-
def nurture(data: RepoData, fork: RepoOut, updates: Nel[Update.ForArtifactId]): F[Unit] = {
64-
66+
def nurture(data: RepoData, fork: RepoOut, updates: Nel[Update.ForArtifactId]): F[Unit] =
6567

6668
for {
6769
_ <- logger.info(s"Nurture ${data.repo.show}")
6870
baseBranch <- cloneAndSync(data.repo, fork)
69-
applicableUpdateSets <- updates.traverse(update => editAlg.findUpdateReplacements(fork.repo, data.config, update).map(update -> _)).map {
70-
x => x.toList.groupMap(_._2)(_._1).map {
71-
case (r, a) => ApplicableUpdateSet(r, a)
71+
applicableUpdateSets <- updates
72+
.traverse(update =>
73+
editAlg.findUpdateReplacements(fork.repo, data.config, update).map(update -> _)
74+
)
75+
.map { x =>
76+
x.toList.groupMap(_._2)(_._1).map { case (r, a) =>
77+
UpdatesForGivenEdit(r, a)
78+
}
7279
}
73-
}
7480

7581
(grouped, notGrouped) = Update.groupByPullRequestGroup(
7682
data.config.pullRequestsOrDefault.groupingOrDefault,
@@ -79,7 +85,6 @@ final class NurtureAlg[F[_]](config: ForgeCfg)(implicit
7985
finalUpdates = Update.groupByGroupId(notGrouped) ++ grouped
8086
_ <- updateDependencies(data, fork.repo, baseBranch, finalUpdates)
8187
} yield ()
82-
}
8388

8489
private def cloneAndSync(repo: Repo, fork: RepoOut): F[Branch] =
8590
for {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import cats.data.NonEmptyList
2121
import io.circe.generic.semiauto.*
2222
import io.circe.{Decoder, Encoder}
2323
import org.scalasteward.core.data.Update
24-
import org.scalasteward.core.nurture.ApplicableUpdateSet
24+
import org.scalasteward.core.nurture.UpdatesForGivenEdit
2525

2626
case class PullRequestGroup(
2727
name: String,
@@ -33,7 +33,7 @@ case class PullRequestGroup(
3333
*/
3434
def matches(update: Update.ForArtifactId): Boolean = filter.exists(_.matches(update))
3535

36-
def matches(updates: ApplicableUpdateSet): Boolean =
36+
def matches(updates: UpdatesForGivenEdit): Boolean =
3737
filter.exists(f => updates.artifactUpdates.exists(update => f.matches(update)))
3838
}
3939

0 commit comments

Comments
 (0)