|
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 | | - |
11 | 3 | import org.scm4j.commons.Version; |
12 | 4 | import org.scm4j.commons.progress.IProgress; |
13 | 5 | import org.scm4j.commons.progress.ProgressConsole; |
14 | 6 | import org.scm4j.releaser.branch.DevelopBranch; |
15 | 7 | import org.scm4j.releaser.branch.ReleaseBranchCurrent; |
16 | 8 | import org.scm4j.releaser.branch.ReleaseBranchFactory; |
17 | 9 | import org.scm4j.releaser.branch.ReleaseBranchPatch; |
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; |
| 10 | +import org.scm4j.releaser.conf.*; |
23 | 11 | import org.scm4j.releaser.exceptions.EMinorUpgradeDowngrade; |
24 | 12 | import org.scm4j.releaser.exceptions.ENoReleaseBranchForPatch; |
25 | 13 | import org.scm4j.releaser.exceptions.ENoReleases; |
|
29 | 17 | import org.scm4j.vcs.api.VCSTag; |
30 | 18 | import org.scm4j.vcs.api.WalkDirection; |
31 | 19 |
|
| 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.Utils.reportDuration; |
| 27 | + |
32 | 28 | public class ExtendedStatusBuilder { |
33 | 29 |
|
34 | 30 | private static final int PARALLEL_CALCULATION_AWAIT_TIME = 500; |
@@ -93,15 +89,8 @@ private ExtendedStatus getMinorStatus(Component comp, CachedStatuses cache, IPro |
93 | 89 | BuildStatus status; |
94 | 90 | if (comp.getVersion().isLocked()) { |
95 | 91 | ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<>(); |
96 | | - Utils.async(rb.getMDeps(), (mdep) -> { |
97 | | - try { |
98 | | - recursiveGetAndCacheStatus(cache, progress, subComponentsLocal, mdep, false); |
99 | | - } catch (Exception e) { |
100 | | - cache.remove(repo.getUrl()); |
101 | | - throw e; |
102 | | - } |
103 | | - }); |
104 | | - |
| 92 | + recursiveGetAndCacheStatusAsync(rb, cache, progress, repo, subComponentsLocal); |
| 93 | + |
105 | 94 | for (Component mdep : rb.getMDeps()) { |
106 | 95 | subComponents.put(mdep, subComponentsLocal.get(mdep)); |
107 | 96 | } |
@@ -301,15 +290,8 @@ private Boolean isNeedToFork(Component comp, ReleaseBranchCurrent rb, CachedStat |
301 | 290 | LinkedHashMap<Component, ExtendedStatus> subComponents, VCSRepository repo, Boolean hasDelayedTag) { |
302 | 291 |
|
303 | 292 | ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<>(); |
304 | | - Utils.async(rb.getMDeps(), (mdep) -> { |
305 | | - try { |
306 | | - recursiveGetAndCacheStatus(cache, progress, subComponentsLocal, mdep, false); |
307 | | - } catch (Exception e) { |
308 | | - cache.remove(repo.getUrl()); |
309 | | - throw e; |
310 | | - } |
311 | | - }); |
312 | | - |
| 293 | + recursiveGetAndCacheStatusAsync(rb, cache, progress, repo, subComponentsLocal); |
| 294 | + |
313 | 295 | for (Component mdep : rb.getMDeps()) { |
314 | 296 | subComponents.put(mdep, subComponentsLocal.get(mdep)); |
315 | 297 | } |
@@ -344,4 +326,15 @@ private Boolean isNeedToFork(Component comp, ReleaseBranchCurrent rb, CachedStat |
344 | 326 |
|
345 | 327 | return false; |
346 | 328 | } |
| 329 | + |
| 330 | + private void recursiveGetAndCacheStatusAsync(ReleaseBranchCurrent rb, CachedStatuses cache, IProgress progress, VCSRepository repo, ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal) { |
| 331 | + Utils.async(rb.getMDeps(), (mdep) -> { |
| 332 | + try { |
| 333 | + recursiveGetAndCacheStatus(cache, progress, subComponentsLocal, mdep, false); |
| 334 | + } catch (Exception e) { |
| 335 | + cache.remove(repo.getUrl()); |
| 336 | + throw e; |
| 337 | + } |
| 338 | + }); |
| 339 | + } |
347 | 340 | } |
0 commit comments