Fixed task names
This commit is contained in:
@@ -82,6 +82,9 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
.stream()
|
||||
.map(entry -> new ProjectVersion(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toSet());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Will apply the following fixed versions {}", projectVersions);
|
||||
}
|
||||
return new Versions(projectVersions).toProjectVersions();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.springframework.cloud.release.internal.spring;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class ConsoleInputStepSkipper implements StepSkipper {
|
||||
|
||||
@Override public boolean skipStep() {
|
||||
String input = chosenOption();
|
||||
switch (input.toLowerCase()) {
|
||||
case "s":
|
||||
return true;
|
||||
case "q":
|
||||
System.exit(0);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String chosenOption() {
|
||||
return System.console().readLine();
|
||||
}
|
||||
}
|
||||
@@ -126,16 +126,22 @@ public class SpringReleaser {
|
||||
}
|
||||
filteredProjects = filteredProjects.subList(projectIndex, filteredProjects.size());
|
||||
options.startFrom = "";
|
||||
enforceFullRelease(options);
|
||||
} else if (!options.taskNames.isEmpty()) {
|
||||
filteredProjects = filteredProjects.stream()
|
||||
.filter(project -> options.taskNames.contains(project))
|
||||
.collect(Collectors.toList());
|
||||
options.taskNames = new ArrayList<>();
|
||||
enforceFullRelease(options);
|
||||
}
|
||||
log.info("\n\n\nFor meta-release, will release the projects {}\n\n\n", filteredProjects);
|
||||
return filteredProjects;
|
||||
}
|
||||
|
||||
protected void enforceFullRelease(Options options) {
|
||||
options.fullRelease = true;
|
||||
}
|
||||
|
||||
private File projectFolder() {
|
||||
String workingDir = this.properties.getWorkingDir();
|
||||
return new File(workingDir);
|
||||
@@ -210,7 +216,7 @@ public class SpringReleaser {
|
||||
|
||||
private void printSettingVersionFromFixedVersions(Projects projectsToUpdate) {
|
||||
log.info("\n\n\n=== RETRIEVED VERSIONS ===\n\nWill use the fixed versions"
|
||||
+ " of projects\n\n {}", projectsToUpdate
|
||||
+ " of projects\n\n{}", projectsToUpdate
|
||||
.stream().map(p -> p.projectName + " => " + p.version)
|
||||
.collect(Collectors.joining("\n")));
|
||||
}
|
||||
@@ -223,7 +229,5 @@ public class SpringReleaser {
|
||||
+ "there is at least one SNAPSHOT library version in the Spring Cloud Release project");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.springframework.cloud.release.internal.spring;
|
||||
|
||||
/**
|
||||
* Reads input (e.g. from the console)
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
interface StepSkipper {
|
||||
boolean skipStep();
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
class Task {
|
||||
|
||||
static StepSkipper stepSkipper = new ConsoleInputStepSkipper();
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private static final String MSG = "\nPress 'q' to quit, 's' to skip, any key to continue\n\n";
|
||||
|
||||
@@ -46,7 +48,7 @@ class Task {
|
||||
boolean interactive = args.interactive;
|
||||
printLog(interactive);
|
||||
if (interactive) {
|
||||
boolean skipStep = skipStep();
|
||||
boolean skipStep = stepSkipper.skipStep();
|
||||
if (!skipStep) {
|
||||
consumer.accept(args);
|
||||
}
|
||||
@@ -63,21 +65,4 @@ class Task {
|
||||
private void printLog(boolean interactive) {
|
||||
log.info("\n\n\n=== {} ===\n\n{} {}\n\n", header, description, interactive ? MSG : "");
|
||||
}
|
||||
|
||||
boolean skipStep() {
|
||||
String input = chosenOption();
|
||||
switch (input.toLowerCase()) {
|
||||
case "s":
|
||||
return true;
|
||||
case "q":
|
||||
System.exit(0);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String chosenOption() {
|
||||
return System.console().readLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,13 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -76,6 +79,12 @@ public class AcceptanceTests {
|
||||
FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
|
||||
BDDMockito.given(this.saganClient.getProject(anyString()))
|
||||
.willReturn(newProject());
|
||||
Task.stepSkipper = () -> false;
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
Task.stepSkipper = new ConsoleInputStepSkipper();
|
||||
}
|
||||
|
||||
private Project newProject() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import edu.emory.mathcs.backport.java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -41,6 +42,12 @@ public class OptionsProcessorTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks);
|
||||
Task.stepSkipper = () -> false;
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
Task.stepSkipper = new ConsoleInputStepSkipper();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -261,11 +268,7 @@ public class OptionsProcessorTests {
|
||||
}
|
||||
|
||||
static Task task(String name, String shortName, String header, String description, Consumer<Args> function) {
|
||||
return new Task(name, shortName, header, description, function) {
|
||||
@Override String chosenOption() {
|
||||
return "whatever";
|
||||
}
|
||||
};
|
||||
return new Task(name, shortName, header, description, function);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user