Updated docs
This commit is contained in:
@@ -734,6 +734,12 @@ public class ReleaserProperties implements Serializable {
|
||||
}
|
||||
|
||||
public static class Sagan implements Serializable {
|
||||
|
||||
/**
|
||||
* If set to {@code false} will not update Sagan
|
||||
*/
|
||||
private boolean updateSagan = true;
|
||||
|
||||
/**
|
||||
* URL to the Sagan API
|
||||
*/
|
||||
@@ -747,6 +753,14 @@ public class ReleaserProperties implements Serializable {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public boolean isUpdateSagan() {
|
||||
return this.updateSagan;
|
||||
}
|
||||
|
||||
public void setUpdateSagan(boolean updateSagan) {
|
||||
this.updateSagan = updateSagan;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "Sagan{" + "baseUrl='" + this.baseUrl + '\'' + '}';
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
@@ -16,12 +18,19 @@ public class SaganUpdater {
|
||||
private static final Logger log = LoggerFactory.getLogger(SaganUpdater.class);
|
||||
|
||||
private final SaganClient saganClient;
|
||||
private final ReleaserProperties releaserProperties;
|
||||
|
||||
public SaganUpdater(SaganClient saganClient) {
|
||||
public SaganUpdater(SaganClient saganClient, ReleaserProperties releaserProperties) {
|
||||
this.saganClient = saganClient;
|
||||
this.releaserProperties = releaserProperties;
|
||||
}
|
||||
|
||||
public void updateSagan(String branch, ProjectVersion originalVersion, ProjectVersion version) {
|
||||
if (!releaserProperties.getSagan().isUpdateSagan()) {
|
||||
log.info("Will not update sagan, since the switch to do so "
|
||||
+ "is off. Set [releaser.sagan.update-sagan] to [true] to change that");
|
||||
return;
|
||||
}
|
||||
ReleaseUpdate update = releaseUpdate(branch, originalVersion, version);
|
||||
updateSaganForNonSnapshot(branch, originalVersion, version);
|
||||
log.info("Updating Sagan with \n\n{}", update);
|
||||
|
||||
@@ -3,16 +3,13 @@ package org.springframework.cloud.release.internal.sagan;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.BDDMockito;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
|
||||
import static org.mockito.BDDMockito.then;
|
||||
@@ -22,11 +19,11 @@ import static org.mockito.Mockito.never;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SaganUpdaterTest {
|
||||
|
||||
@Mock SaganClient saganClient;
|
||||
@InjectMocks SaganUpdater saganUpdater;
|
||||
SaganClient saganClient = Mockito.mock(SaganClient.class);
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, this.properties);
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -47,6 +44,14 @@ public class SaganUpdaterTest {
|
||||
return release;
|
||||
}
|
||||
|
||||
@Test public void should_not_update_sagan_when_switch_is_off() throws Exception {
|
||||
this.properties.getSagan().setUpdateSagan(false);
|
||||
|
||||
this.saganUpdater.updateSagan("master", version("1.0.0.M1"), version("1.0.0.M1"));
|
||||
|
||||
then(this.saganClient).shouldHaveZeroInteractions();
|
||||
}
|
||||
|
||||
@Test public void should_update_sagan_for_milestone() throws Exception {
|
||||
this.saganUpdater.updateSagan("master", version("1.0.0.M1"), version("1.0.0.M1"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user