|
1 | 1 | package org.scm4j.releaser; |
2 | 2 |
|
| 3 | +import static org.scm4j.releaser.Utils.reportDuration; |
| 4 | + |
| 5 | +import java.util.ArrayList; |
| 6 | +import java.util.LinkedHashMap; |
| 7 | +import java.util.List; |
| 8 | +import java.util.concurrent.ConcurrentHashMap; |
| 9 | +import java.util.function.Function; |
| 10 | + |
3 | 11 | import org.scm4j.commons.Version; |
4 | 12 | import org.scm4j.commons.progress.IProgress; |
5 | 13 | import org.scm4j.commons.progress.ProgressConsole; |
6 | 14 | import org.scm4j.releaser.branch.DevelopBranch; |
7 | 15 | import org.scm4j.releaser.branch.ReleaseBranchCurrent; |
8 | 16 | import org.scm4j.releaser.branch.ReleaseBranchFactory; |
9 | 17 | import org.scm4j.releaser.branch.ReleaseBranchPatch; |
10 | | -import org.scm4j.releaser.conf.*; |
| 18 | +import org.scm4j.releaser.conf.Component; |
| 19 | +import org.scm4j.releaser.conf.DelayedTag; |
| 20 | +import org.scm4j.releaser.conf.DelayedTagsFile; |
| 21 | +import org.scm4j.releaser.conf.VCSRepository; |
| 22 | +import org.scm4j.releaser.conf.VCSRepositoryFactory; |
11 | 23 | import org.scm4j.releaser.exceptions.EMinorUpgradeDowngrade; |
12 | 24 | import org.scm4j.releaser.exceptions.ENoReleaseBranchForPatch; |
13 | 25 | import org.scm4j.releaser.exceptions.ENoReleases; |
|
17 | 29 | import org.scm4j.vcs.api.VCSTag; |
18 | 30 | import org.scm4j.vcs.api.WalkDirection; |
19 | 31 |
|
20 | | -import java.util.ArrayList; |
21 | | -import java.util.LinkedHashMap; |
22 | | -import java.util.List; |
23 | | -import java.util.concurrent.ConcurrentHashMap; |
24 | | -import java.util.function.Function; |
25 | | - |
26 | | -import static org.scm4j.releaser.Constants.ZERO_PATCH; |
27 | | -import static org.scm4j.releaser.Utils.reportDuration; |
28 | | - |
29 | 32 | public class ExtendedStatusBuilder { |
30 | 33 |
|
31 | 34 | private static final int PARALLEL_CALCULATION_AWAIT_TIME = 500; |
@@ -217,34 +220,37 @@ private <T> T walkOnCommits(VCSRepository repo, ReleaseBranchPatch rb, Function< |
217 | 220 | } while (commits.size() >= COMMITS_RANGE_LIMIT); |
218 | 221 | return null; |
219 | 222 | } |
220 | | - |
| 223 | + |
221 | 224 | private boolean areMDepsPatchesActual(Component rootComp, VCSRepository repo, List<Component> mDeps, CachedStatuses cache) { |
222 | 225 | for (Component mDep : mDeps) { |
223 | 226 | String url = repoFactory.getUrl(mDep); |
224 | | - Version nextMDepVersion = cache.get(url).getNextVersion(); |
225 | | - if (!nextMDepVersion.toReleaseNoPatch().equals(mDep.getVersion().toReleaseNoPatch())) { |
| 227 | + Version nextVersion = cache.get(url).getNextVersion(); |
| 228 | + |
| 229 | + // Any component `nextVersion`.truncatePatch is not equal to one mentioned in `mdeps` -> error (disallow minor upgrade/downgrade) |
| 230 | + if (!nextVersion.toReleaseNoPatch().equals(mDep.getVersion().toReleaseNoPatch())) { |
226 | 231 | cache.remove(repo.getUrl()); |
227 | | - throw new EMinorUpgradeDowngrade(rootComp, mDep, nextMDepVersion.toPreviousPatch()); |
| 232 | + throw new EMinorUpgradeDowngrade(rootComp, mDep, nextVersion.toPreviousPatch()); |
228 | 233 | } |
| 234 | + |
| 235 | + |
229 | 236 | 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()); |
| 237 | + Version verToActualizeOn ; |
| 238 | + if (mdf.getDelayedTagByUrl(url) != null) { // if delayed tag |
| 239 | + verToActualizeOn = nextVersion; |
233 | 240 | } else { |
234 | | - cachedMDepPatch = Integer.parseInt(nextMDepVersion.getPatch()); |
| 241 | + verToActualizeOn = nextVersion.toPreviousPatch(); |
235 | 242 | } |
236 | | - |
| 243 | + |
237 | 244 | Integer mDepPatch = Integer.parseInt(mDep.getVersion().getPatch()); |
238 | | - if (cachedMDepPatch == mDepPatch) { |
239 | | - continue; |
240 | | - } |
| 245 | + Integer nextVersionPatch = Integer.parseInt(verToActualizeOn.getPatch()); |
241 | 246 |
|
242 | | - if (cachedMDepPatch < mDepPatch) { |
| 247 | + // Any component `nextVersion`.patch is less than one mentioned in `mdeps` -> error (patch upgrade only is allowed) |
| 248 | + if (nextVersionPatch < mDepPatch) { |
243 | 249 | cache.remove(repo.getUrl()); |
244 | | - throw new EMinorUpgradeDowngrade(rootComp, mDep, nextMDepVersion.toPreviousPatch()); |
| 250 | + throw new EMinorUpgradeDowngrade(rootComp, mDep, verToActualizeOn); |
245 | 251 | } |
246 | | - |
247 | | - if (!(nextMDepVersion.getPatch().equals(ZERO_PATCH) && mdf.getDelayedTagByUrl(url) != null)) { |
| 252 | + |
| 253 | + if (nextVersionPatch > mDepPatch) { |
248 | 254 | return false; |
249 | 255 | } |
250 | 256 | } |
|
0 commit comments