Skip to content

Commit 74fe582

Browse files
committed
EMinorUpgradeDowngrade on minor ACTUALIZE_PATCHES #56
1 parent 48ee6cb commit 74fe582

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private ExtendedStatus getMinorStatus(Component comp, CachedStatuses cache, IPro
110110
status = BuildStatus.LOCK;
111111
} else if (hasMDepsNotInDONEStatus(rb.getMDeps(), cache)) {
112112
status = BuildStatus.BUILD_MDEPS;
113-
} else if (!areMDepsPatchesActual(comp, repo, rb.getMDeps(), cache)) {
113+
} else if (!areMDepsPatchesActualForMinor(rb.getMDeps(), cache)) {
114114
status = BuildStatus.ACTUALIZE_PATCHES;
115115
} else {
116116
status = BuildStatus.BUILD;
@@ -156,7 +156,7 @@ private ExtendedStatus getPatchStatus(Component comp, CachedStatuses cache, IPro
156156

157157
if (hasMDepsNotInDONEStatus(rb.getMDeps(), cache)) {
158158
buildStatus = BuildStatus.BUILD_MDEPS;
159-
} else if (!areMDepsPatchesActual(comp, repo, rb.getMDeps(), cache)) {
159+
} else if (!areMDepsPatchesActualForPatch(comp, repo, rb.getMDeps(), cache)) {
160160
buildStatus = BuildStatus.ACTUALIZE_PATCHES;
161161
} else if (reportDuration(() -> noValueableCommitsAfterLastTag(repo, rb), "is release branch modified check", comp, progress)) {
162162
buildStatus = BuildStatus.DONE;
@@ -221,7 +221,21 @@ private <T> T walkOnCommits(VCSRepository repo, ReleaseBranchPatch rb, Function<
221221
return null;
222222
}
223223

224-
private boolean areMDepsPatchesActual(Component rootComp, VCSRepository repo, List<Component> mDeps, CachedStatuses cache) {
224+
private boolean areMDepsPatchesActualForMinor(List<Component> mDeps, CachedStatuses cache) {
225+
for (Component mDep : mDeps) {
226+
String url = repoFactory.getUrl(mDep);
227+
Version nextMDepVersion = cache.get(url).getNextVersion();
228+
if (!nextMDepVersion.equals(mDep.getVersion().toNextPatch())) {
229+
DelayedTagsFile mdf = new DelayedTagsFile();
230+
if (!(nextMDepVersion.getPatch().equals(Constants.ZERO_PATCH) && mdf.getDelayedTagByUrl(url) != null)) {
231+
return false;
232+
}
233+
}
234+
}
235+
return true;
236+
}
237+
238+
private boolean areMDepsPatchesActualForPatch(Component rootComp, VCSRepository repo, List<Component> mDeps, CachedStatuses cache) {
225239
for (Component mDep : mDeps) {
226240
String url = repoFactory.getUrl(mDep);
227241
Version nextVersion = cache.get(url).getNextVersion();
@@ -287,7 +301,6 @@ private Boolean isNeedToFork(Component comp, ReleaseBranchCurrent rb, CachedStat
287301
return true;
288302
}
289303

290-
291304
if (rb.getVersion().getPatch().equals(Constants.ZERO_PATCH)) {
292305
if (!hasDelayedTag) {
293306
return false;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.scm4j.releaser.actions.IAction;
66
import org.scm4j.releaser.branch.ReleaseBranchCurrent;
77
import org.scm4j.releaser.branch.ReleaseBranchFactory;
8+
import org.scm4j.releaser.cli.CLICommand;
89
import org.scm4j.releaser.conf.Component;
910
import org.scm4j.releaser.conf.MDepsFile;
1011
import org.scm4j.releaser.exceptions.EBuildOnNotForkedRelease;
@@ -152,4 +153,19 @@ public void testBuiltRootIfNestedBuiltAndModified() {
152153
crb = ReleaseBranchFactory.getCRB(repoUnTillDb);
153154
assertEquals(env.getUnTillDbVer().toReleaseZeroPatch().toNextPatch(), crb.getVersion());
154155
}
156+
157+
@Test
158+
public void TestMinorUpgradeIsOK() {
159+
fork(compUnTill);
160+
build(compUnTillDb);
161+
// add feature to trunk and release branch
162+
env.generateFeatureCommit(env.getUnTillDbVCS(), null, "feature added");
163+
164+
// release next unTillDb version
165+
forkAndBuild(compUnTillDb, 2);
166+
//execAndGetActionBuildDelayedTag(compUnTillDb);
167+
168+
// expect no EMinorUpgradeDowngrade exception because areMDepsPatchesActualForMinor should be used for minor
169+
execAndGetAction(CLICommand.STATUS.getCmdLineStr(), compUBL.getCoords().toString());
170+
}
155171
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ private CLI execAndGetCLI(Runnable preExec, String... args) {
377377
private IAction execAndGetAction(Runnable preExec, String... args) {
378378
CLI cli = execAndGetCLI(preExec, args);
379379
IAction action = cli.getAction();
380-
action.toString(); // cover
380+
if (action != null) {
381+
action.toString(); // cover
382+
}
381383
return action;
382384
}
383385

@@ -386,7 +388,7 @@ protected ExtendedStatus execAndGetNode(Runnable preExec, String... args) {
386388
return cli.getNode();
387389
}
388390

389-
private IAction execAndGetAction(String... args) {
391+
protected IAction execAndGetAction(String... args) {
390392
return execAndGetAction(null, args);
391393
}
392394

0 commit comments

Comments
 (0)