Skip to content

Commit 6434fa8

Browse files
committed
Merge branch 'master' of https://github.com/scm4j/scm4j-releaser
2 parents 36af4c2 + 69ff654 commit 6434fa8

File tree

6 files changed

+280
-317
lines changed

6 files changed

+280
-317
lines changed

src/main/java/org/scm4j/releaser/ExtendedStatusBuilder.java

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
package org.scm4j.releaser;
22

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-
113
import org.scm4j.commons.Version;
124
import org.scm4j.commons.progress.IProgress;
135
import org.scm4j.commons.progress.ProgressConsole;
146
import org.scm4j.releaser.branch.DevelopBranch;
157
import org.scm4j.releaser.branch.ReleaseBranchCurrent;
168
import org.scm4j.releaser.branch.ReleaseBranchFactory;
179
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.*;
2311
import org.scm4j.releaser.exceptions.EMinorUpgradeDowngrade;
2412
import org.scm4j.releaser.exceptions.ENoReleaseBranchForPatch;
2513
import org.scm4j.releaser.exceptions.ENoReleases;
@@ -29,6 +17,14 @@
2917
import org.scm4j.vcs.api.VCSTag;
3018
import org.scm4j.vcs.api.WalkDirection;
3119

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+
3228
public class ExtendedStatusBuilder {
3329

3430
private static final int PARALLEL_CALCULATION_AWAIT_TIME = 500;
@@ -93,15 +89,8 @@ private ExtendedStatus getMinorStatus(Component comp, CachedStatuses cache, IPro
9389
BuildStatus status;
9490
if (comp.getVersion().isLocked()) {
9591
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+
10594
for (Component mdep : rb.getMDeps()) {
10695
subComponents.put(mdep, subComponentsLocal.get(mdep));
10796
}
@@ -301,15 +290,8 @@ private Boolean isNeedToFork(Component comp, ReleaseBranchCurrent rb, CachedStat
301290
LinkedHashMap<Component, ExtendedStatus> subComponents, VCSRepository repo, Boolean hasDelayedTag) {
302291

303292
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+
313295
for (Component mdep : rb.getMDeps()) {
314296
subComponents.put(mdep, subComponentsLocal.get(mdep));
315297
}
@@ -344,4 +326,15 @@ private Boolean isNeedToFork(Component comp, ReleaseBranchCurrent rb, CachedStat
344326

345327
return false;
346328
}
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+
}
347340
}

src/test/java/org/scm4j/releaser/WorkflowBuildTest.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
package org.scm4j.releaser;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.fail;
5-
import static org.mockito.Matchers.eq;
6-
import static org.mockito.Mockito.atLeast;
7-
import static org.mockito.Mockito.doThrow;
8-
import static org.mockito.Mockito.spy;
9-
import static org.mockito.Mockito.verify;
10-
11-
import java.nio.charset.StandardCharsets;
12-
import java.util.Map;
13-
import java.util.concurrent.ConcurrentHashMap;
14-
153
import org.apache.commons.io.FileUtils;
164
import org.junit.Test;
175
import org.scm4j.commons.progress.ProgressConsole;
@@ -23,6 +11,14 @@
2311
import org.scm4j.releaser.exceptions.EBuildOnNotForkedRelease;
2412
import org.scm4j.releaser.exceptions.ENoBuilder;
2513
import org.yaml.snakeyaml.Yaml;
14+
15+
import java.nio.charset.StandardCharsets;
16+
import java.util.Map;
17+
import java.util.concurrent.ConcurrentHashMap;
18+
19+
import static org.junit.Assert.*;
20+
import static org.mockito.Matchers.eq;
21+
import static org.mockito.Mockito.*;
2622
public class WorkflowBuildTest extends WorkflowTestBase {
2723

2824
@Test
@@ -181,7 +177,7 @@ public void testShouldRemoveFromCacheOnErrorsOnMinor() {
181177
CachedStatuses cache = spy(new CachedStatuses());
182178
RuntimeException testException = new RuntimeException("");
183179
ProgressConsole pc = new ProgressConsole();
184-
ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<Component, ExtendedStatus>();
180+
ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<>();
185181
Component versionedUBL = compUBL.clone("1.0");
186182
doThrow(testException).when(esb).recursiveGetAndCacheStatus(cache, pc, subComponentsLocal, compUnTillDb, false);
187183

@@ -200,7 +196,7 @@ public void testShouldRemoveFromCacheOnErrorsOnPatch() {
200196
CachedStatuses cache = spy(new CachedStatuses());
201197
RuntimeException testException = new RuntimeException("");
202198
ProgressConsole pc = new ProgressConsole();
203-
ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<Component, ExtendedStatus>();
199+
ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<>();
204200
Component versionedUBL = compUBL.clone(getCrbVersion(compUBL));
205201
Component versionedUnTillDb = new Component("eu.untill:unTillDb:2.59.0#comment 3");
206202
doThrow(testException).when(esb).recursiveGetAndCacheStatus(cache, pc, subComponentsLocal, versionedUnTillDb, true);
@@ -219,7 +215,7 @@ public void testShouldRemoveFromCacheOnErrorsIsNeedToFork() {
219215
CachedStatuses cache = spy(new CachedStatuses());
220216
RuntimeException testException = new RuntimeException("");
221217
ProgressConsole pc = new ProgressConsole();
222-
ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<Component, ExtendedStatus>();
218+
ConcurrentHashMap<Component, ExtendedStatus> subComponentsLocal = new ConcurrentHashMap<>();
223219
doThrow(testException).when(esb).recursiveGetAndCacheStatus(cache, pc, subComponentsLocal, compUnTillDb, false);
224220

225221
try {

0 commit comments

Comments
 (0)