Skip to content

Commit 39b618f

Browse files
committed
Println debugging
1 parent 0ab2a67 commit 39b618f

File tree

2 files changed

+49
-31
lines changed

2 files changed

+49
-31
lines changed

modules/core/src/main/scala/org/scalasteward/core/edit/EditAlg.scala

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,44 @@ final class EditAlg[F[_]](implicit
5050
update: Update.Single,
5151
preCommit: F[Unit] = F.unit
5252
): F[List[EditAttempt]] =
53-
findUpdateReplacements(data.repo, data.config, update).flatMap {
54-
case Nil => logger.warn(s"Unable to bump version for update ${update.show}").as(Nil)
55-
case updateReplacements =>
56-
for {
57-
_ <- preCommit
58-
(preMigrations, postMigrations) = scalafixMigrationsFinder.findMigrations(update)
59-
preScalafixEdits <- runScalafixMigrations(data.repo, data.config, preMigrations)
60-
// PreUpdate migrations could invalidate previously found replacements,
61-
// so we find them again if the migrations produced any changes.
62-
freshReplacements <-
63-
if (preScalafixEdits.flatMap(_.commits).isEmpty) F.pure(updateReplacements)
64-
else findUpdateReplacements(data.repo, data.config, update)
65-
updateEdit <- applyUpdateReplacements(data, update, freshReplacements)
66-
postScalafixEdits <- runScalafixMigrations(data.repo, data.config, postMigrations)
67-
hooksEdits <- hookExecutor.execPostUpdateHooks(data, update)
68-
} yield preScalafixEdits ++ updateEdit ++ postScalafixEdits ++ hooksEdits
53+
{
54+
findUpdateReplacements(data.repo, data.config, update).flatMap {
55+
case Nil =>
56+
logger.warn(s"Unable to bump version for update ${update.show}").as(Nil)
57+
case updateReplacements =>
58+
for {
59+
_ <- preCommit
60+
(preMigrations, postMigrations) = scalafixMigrationsFinder.findMigrations(update)
61+
preScalafixEdits <- runScalafixMigrations(data.repo, data.config, preMigrations)
62+
// PreUpdate migrations could invalidate previously found replacements,
63+
// so we find them again if the migrations produced any changes.
64+
freshReplacements <-
65+
if (preScalafixEdits.flatMap(_.commits).isEmpty) F.pure(updateReplacements)
66+
else findUpdateReplacements(data.repo, data.config, update)
67+
updateEdit <- applyUpdateReplacements(data, update, freshReplacements)
68+
postScalafixEdits <- runScalafixMigrations(data.repo, data.config, postMigrations)
69+
hooksEdits <- hookExecutor.execPostUpdateHooks(data, update)
70+
} yield {
71+
preScalafixEdits ++ updateEdit ++ postScalafixEdits ++ hooksEdits
72+
}
73+
}
6974
}
7075

7176
private def findUpdateReplacements(
7277
repo: Repo,
7378
config: RepoConfig,
7479
update: Update.Single
7580
): F[List[Substring.Replacement]] =
76-
for {
77-
versionPositions <- scannerAlg.findVersionPositions(repo, config, update.currentVersion)
78-
modulePositions <- scannerAlg.findModulePositions(repo, config, update.dependencies)
79-
} yield Selector.select(update, versionPositions, modulePositions)
81+
{
82+
println("findUpdateReplacements")
83+
println(s" update = $update")
84+
for {
85+
versionPositions <- scannerAlg.findVersionPositions(repo, config, update.currentVersion)
86+
_ = println(s" versionPositions = ${versionPositions}")
87+
modulePositions <- scannerAlg.findModulePositions(repo, config, update.dependencies)
88+
_ = println(s" modulePositions = ${modulePositions}")
89+
} yield Selector.select(update, versionPositions, modulePositions)
90+
}
8091

8192
private def runScalafixMigrations(
8293
repo: Repo,
@@ -103,17 +114,23 @@ final class EditAlg[F[_]](implicit
103114
update: Update.Single,
104115
updateReplacements: List[Substring.Replacement]
105116
): F[Option[EditAttempt]] =
106-
for {
107-
repoDir <- workspaceAlg.repoDir(data.repo)
108-
replacementsByPath = updateReplacements.groupBy(_.position.path).toList
109-
_ <- replacementsByPath.traverse { case (path, replacements) =>
110-
fileAlg.editFile(repoDir / path, Substring.Replacement.applyAll(replacements))
111-
}
112-
_ <- reformatChangedFiles(data)
113-
msgTemplate = data.config.commits.messageOrDefault
114-
commitMsg = CommitMsg.replaceVariables(msgTemplate)(update, data.repo.branch)
115-
maybeCommit <- gitAlg.commitAllIfDirty(data.repo, commitMsg)
116-
} yield maybeCommit.map(UpdateEdit(update, _))
117+
{
118+
println("applyUpdateReplacements")
119+
println(s" data = ${data}")
120+
println(s" update = ${update}")
121+
println(s" updateReplacements = ${updateReplacements}")
122+
for {
123+
repoDir <- workspaceAlg.repoDir(data.repo)
124+
replacementsByPath = updateReplacements.groupBy(_.position.path).toList
125+
_ <- replacementsByPath.traverse { case (path, replacements) =>
126+
fileAlg.editFile(repoDir / path, Substring.Replacement.applyAll(replacements))
127+
}
128+
_ <- reformatChangedFiles(data)
129+
msgTemplate = data.config.commits.messageOrDefault
130+
commitMsg = CommitMsg.replaceVariables(msgTemplate)(update, data.repo.branch)
131+
maybeCommit <- gitAlg.commitAllIfDirty(data.repo, commitMsg)
132+
} yield maybeCommit.map(UpdateEdit(update, _))
133+
}
117134

118135
private def reformatChangedFiles(data: RepoData): F[Unit] = {
119136
val reformat =

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ final class NurtureAlg[F[_]](config: VCSCfg)(implicit
9393
_ <- logger.info(s"Process update ${data.update.show}")
9494
head = vcs.listingBranch(config.tpe, data.fork, data.updateBranch)
9595
pullRequests <- vcsApiAlg.listPullRequests(data.repo, head, data.baseBranch)
96+
.map(_.take(0)) // Debug
9697
result <- pullRequests.headOption match {
9798
case Some(pr) if pr.state.isClosed && data.update.isInstanceOf[Update.Single] =>
9899
logger.info(s"PR ${pr.html_url} is closed") >>

0 commit comments

Comments
 (0)