@@ -50,33 +50,44 @@ final class EditAlg[F[_]](implicit
50
50
update : Update .Single ,
51
51
preCommit : F [Unit ] = F .unit
52
52
): 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
+ }
69
74
}
70
75
71
76
private def findUpdateReplacements (
72
77
repo : Repo ,
73
78
config : RepoConfig ,
74
79
update : Update .Single
75
80
): 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
+ }
80
91
81
92
private def runScalafixMigrations (
82
93
repo : Repo ,
@@ -103,17 +114,23 @@ final class EditAlg[F[_]](implicit
103
114
update : Update .Single ,
104
115
updateReplacements : List [Substring .Replacement ]
105
116
): 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
+ }
117
134
118
135
private def reformatChangedFiles (data : RepoData ): F [Unit ] = {
119
136
val reformat =
0 commit comments