Skip to content

Commit

Permalink
Check if version is bumped already on tag command #44
Browse files Browse the repository at this point in the history
  • Loading branch information
host6 committed Jan 18, 2018
1 parent 39eba65 commit c81dada
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/main/java/org/scm4j/releaser/scmactions/SCMActionTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.scm4j.releaser.Utils;
import org.scm4j.releaser.actions.ActionAbstract;
import org.scm4j.releaser.actions.IAction;
import org.scm4j.releaser.branch.ReleaseBranchFactory;
import org.scm4j.releaser.conf.*;
import org.scm4j.vcs.api.IVCS;
import org.scm4j.vcs.api.exceptions.EVCSTagExists;
Expand Down Expand Up @@ -42,11 +43,13 @@ protected void executeAction(IProgress progress) {
}

Version nextPatchVersion = delayedTagVersion.toNextPatch();
Version crbVersion = ReleaseBranchFactory.getCRB(repo).getVersion();
if (!crbVersion.isGreaterThan(nextPatchVersion) && !crbVersion.equals(nextPatchVersion)) {
Utils.reportDuration(() -> vcs.setFileContent(releaseBranchName, Utils.VER_FILE_NAME, nextPatchVersion.toString(),
LogTag.SCM_VER + " " + nextPatchVersion),
"bump patch version in release branch: " + nextPatchVersion, null, progress);
}

Utils.reportDuration(() -> vcs.setFileContent(releaseBranchName, Utils.VER_FILE_NAME, nextPatchVersion.toString(),
LogTag.SCM_VER + " " + nextPatchVersion),
"bump patch version in release branch: " + nextPatchVersion, null, progress);

cf.removeRevisionByUrl(repo.getUrl());
}

Expand Down
37 changes: 36 additions & 1 deletion src/test/java/org/scm4j/releaser/WorkflowDelayedTagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.scm4j.releaser.conf.DelayedTagsFile;
import org.scm4j.releaser.conf.TagDesc;
import org.scm4j.releaser.conf.VCSRepository;
import org.scm4j.vcs.api.VCSCommit;
import org.scm4j.vcs.api.VCSTag;
import org.scm4j.vcs.api.WalkDirection;

Expand Down Expand Up @@ -210,7 +211,41 @@ public void testMDepTagDelayed() {
action = execAndGetActionFork(compUnTill);
assertActionDoesNothing(action, compUnTill, compUnTillDb, compUBL);
}


@Test
public void testVersionIsBumpedAlreadyOnTag() {
fork(compUnTillDb);
IAction action = execAndGetActionBuildDelayedTag(compUnTillDb);
assertActionDoesBuildDelayedTag(action, compUnTillDb);

ReleaseBranchCurrent crb = ReleaseBranchFactory.getCRB(repoUnTillDb);
VCSCommit headCommit = env.getUnTillDbVCS().setFileContent(crb.getName(), Utils.VER_FILE_NAME,
crb.getVersion().toNextPatch().toString(), "version bumped");

// set tag on unTillDb. Version file should not be changed
action = execAndGetActionTag(compUnTillDb, null);
assertActionDoesTag(action, compUnTillDb);

assertEquals(headCommit, env.getUnTillDbVCS().getHeadCommit(crb.getName()));
}

@Test
public void testVersionIsBumpedFewTimesAlreadyOnTag() {
fork(compUnTillDb);
IAction action = execAndGetActionBuildDelayedTag(compUnTillDb);
assertActionDoesBuildDelayedTag(action, compUnTillDb);

ReleaseBranchCurrent crb = ReleaseBranchFactory.getCRB(repoUnTillDb);
VCSCommit headCommit = env.getUnTillDbVCS().setFileContent(crb.getName(), Utils.VER_FILE_NAME,
crb.getVersion().toNextPatch().toNextPatch().toString(), "version bumped");

// set tag on unTillDb. Version file should not be changed
action = execAndGetActionTag(compUnTillDb, null);
assertActionDoesTag(action, compUnTillDb);

assertEquals(headCommit, env.getUnTillDbVCS().getHeadCommit(crb.getName()));
}

private boolean isPreHeadCommitTaggedWithVersion(Component comp) {
VCSRepository repo = repoFactory.getVCSRepository(comp);
ReleaseBranchCurrent rb = ReleaseBranchFactory.getCRB(repo);
Expand Down

0 comments on commit c81dada

Please sign in to comment.