Added a guard for rolling back step
without this change we're not checking the current version in the pom. Regardless of that value we were doing rollbacks and version bumps. with this change we will not perform rollbacks and version bumps for snapshots fixes #18
This commit is contained in:
@@ -55,6 +55,11 @@ public class Releaser {
|
||||
}
|
||||
|
||||
public void rollbackReleaseVersion(File project, ProjectVersion originalVersion, ProjectVersion changedVersion) {
|
||||
ProjectVersion version = new ProjectVersion(project);
|
||||
if (version.isSnapshot()) {
|
||||
log.info("\nCurrent pom contains snapshot version [{}]. Will not proceed with rollback", version.toString());
|
||||
return;
|
||||
}
|
||||
this.projectGitUpdater.revertChangesIfApplicable(project, changedVersion);
|
||||
if (changedVersion.isRelease()) {
|
||||
this.projectBuilder.bumpVersions(originalVersion.bumpedVersion());
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.springframework.cloud.release.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.project.ProjectBuilder;
|
||||
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ReleaserTests {
|
||||
|
||||
@Mock ProjectPomUpdater projectPomUpdater;
|
||||
@Mock ProjectBuilder projectBuilder;
|
||||
@Mock ProjectGitUpdater projectGitUpdater;
|
||||
@InjectMocks Releaser releaser;
|
||||
File pom;
|
||||
|
||||
@Before
|
||||
public void setup() throws URISyntaxException {
|
||||
URI pomUri = ReleaserTests.class.getResource("/projects/project/pom.xml").toURI();
|
||||
this.pom = new File(pomUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackReleaseVersion() throws Exception {
|
||||
this.releaser.rollbackReleaseVersion(this.pom, null, null);
|
||||
|
||||
verifyZeroInteractions(this.projectPomUpdater);
|
||||
verifyZeroInteractions(this.projectBuilder);
|
||||
verifyZeroInteractions(this.projectGitUpdater);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user