|
8 | 8 | import org.scm4j.releaser.branch.ReleaseBranchFactory; |
9 | 9 | import org.scm4j.releaser.branch.ReleaseBranchPatch; |
10 | 10 | import org.scm4j.releaser.conf.*; |
| 11 | +import org.scm4j.releaser.exceptions.EMinorUpgradeDowngrade; |
11 | 12 | import org.scm4j.releaser.exceptions.ENoReleaseBranchForPatch; |
12 | 13 | import org.scm4j.releaser.exceptions.ENoReleases; |
13 | 14 | import org.scm4j.releaser.exceptions.EReleaseMDepsNotLocked; |
@@ -106,7 +107,7 @@ private ExtendedStatus getMinorStatus(Component comp, CachedStatuses cache, IPro |
106 | 107 | status = BuildStatus.LOCK; |
107 | 108 | } else if (hasMDepsNotInDONEStatus(rb.getMDeps(), cache)) { |
108 | 109 | status = BuildStatus.BUILD_MDEPS; |
109 | | - } else if (!areMDepsPatchesActual(rb.getMDeps(), cache)) { |
| 110 | + } else if (!areMDepsPatchesActual(comp, repo, rb.getMDeps(), cache)) { |
110 | 111 | status = BuildStatus.ACTUALIZE_PATCHES; |
111 | 112 | } else { |
112 | 113 | status = BuildStatus.BUILD; |
@@ -152,7 +153,7 @@ private ExtendedStatus getPatchStatus(Component comp, CachedStatuses cache, IPro |
152 | 153 |
|
153 | 154 | if (hasMDepsNotInDONEStatus(rb.getMDeps(), cache)) { |
154 | 155 | buildStatus = BuildStatus.BUILD_MDEPS; |
155 | | - } else if (!areMDepsPatchesActual(rb.getMDeps(), cache)) { |
| 156 | + } else if (!areMDepsPatchesActual(comp, repo, rb.getMDeps(), cache)) { |
156 | 157 | buildStatus = BuildStatus.ACTUALIZE_PATCHES; |
157 | 158 | } else if (reportDuration(() -> noValueableCommitsAfterLastTag(repo, rb), "is release branch modified check", comp, progress)) { |
158 | 159 | buildStatus = BuildStatus.DONE; |
@@ -217,15 +218,34 @@ private <T> T walkOnCommits(VCSRepository repo, ReleaseBranchPatch rb, Function< |
217 | 218 | return null; |
218 | 219 | } |
219 | 220 |
|
220 | | - private boolean areMDepsPatchesActual(List<Component> mDeps, CachedStatuses cache) { |
| 221 | + private boolean areMDepsPatchesActual(Component rootComp, VCSRepository repo, List<Component> mDeps, CachedStatuses cache) { |
221 | 222 | for (Component mDep : mDeps) { |
222 | 223 | String url = repoFactory.getUrl(mDep); |
223 | 224 | Version nextMDepVersion = cache.get(url).getNextVersion(); |
224 | | - if (!nextMDepVersion.equals(mDep.getVersion().toNextPatch())) { |
225 | | - DelayedTagsFile mdf = new DelayedTagsFile(); |
226 | | - if (!(nextMDepVersion.getPatch().equals(ZERO_PATCH) && mdf.getDelayedTagByUrl(url) != null)) { |
227 | | - return false; |
228 | | - } |
| 225 | + if (!nextMDepVersion.toReleaseNoPatch().equals(mDep.getVersion().toReleaseNoPatch())) { |
| 226 | + cache.remove(repo.getUrl()); |
| 227 | + throw new EMinorUpgradeDowngrade(rootComp, mDep, nextMDepVersion.toPreviousPatch()); |
| 228 | + } |
| 229 | + DelayedTagsFile mdf = new DelayedTagsFile(); |
| 230 | + Integer cachedMDepPatch; |
| 231 | + if (!(nextMDepVersion.getPatch().equals(ZERO_PATCH) && mdf.getDelayedTagByUrl(url) != null)) { |
| 232 | + cachedMDepPatch = Integer.parseInt(nextMDepVersion.toPreviousPatch().getPatch()); |
| 233 | + } else { |
| 234 | + cachedMDepPatch = Integer.parseInt(nextMDepVersion.getPatch()); |
| 235 | + } |
| 236 | + |
| 237 | + Integer mDepPatch = Integer.parseInt(mDep.getVersion().getPatch()); |
| 238 | + if (cachedMDepPatch == mDepPatch) { |
| 239 | + continue; |
| 240 | + } |
| 241 | + |
| 242 | + if (cachedMDepPatch < mDepPatch) { |
| 243 | + cache.remove(repo.getUrl()); |
| 244 | + throw new EMinorUpgradeDowngrade(rootComp, mDep, nextMDepVersion.toPreviousPatch()); |
| 245 | + } |
| 246 | + |
| 247 | + if (!(nextMDepVersion.getPatch().equals(ZERO_PATCH) && mdf.getDelayedTagByUrl(url) != null)) { |
| 248 | + return false; |
229 | 249 | } |
230 | 250 | } |
231 | 251 | return true; |
|
0 commit comments