Add tracker open-tickets command to report open tickets for a release.

See #166.
This commit is contained in:
Mark Paluch
2021-01-13 09:15:04 +01:00
parent 7cf21144cd
commit dc86ed2e07
2 changed files with 25 additions and 16 deletions

View File

@@ -36,6 +36,7 @@ import org.springframework.data.release.issues.Tickets;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Project; import org.springframework.data.release.model.Project;
import org.springframework.data.release.model.Projects;
import org.springframework.data.release.model.ReleaseTrains; import org.springframework.data.release.model.ReleaseTrains;
import org.springframework.data.release.model.Train; import org.springframework.data.release.model.Train;
import org.springframework.data.release.model.TrainIteration; import org.springframework.data.release.model.TrainIteration;
@@ -89,24 +90,25 @@ class GitCommands extends TimedCommand {
} }
@CliCommand("git changelog") @CliCommand("git changelog")
public String changelog(@CliOption(key = "", mandatory = true) TrainIteration iteration) throws Exception { public String changelog(@CliOption(key = "", mandatory = true) TrainIteration iteration,
@CliOption(key = "module") String moduleName) {
TrainIteration previousIteration = git.getPreviousIteration(iteration); TrainIteration previousIteration = git.getPreviousIteration(iteration);
return ExecutionUtils.runAndReturn(executor, iteration, module -> { if (StringUtils.hasText(moduleName)) {
ModuleIteration module = iteration.getModule(Projects.requiredByName(moduleName));
List<TicketReference> ticketRefs = git.getTicketReferencesBetween(module.getProject(), previousIteration, List<TicketReference> ticketRefs = git.getTicketReferencesBetween(module.getProject(), previousIteration,
iteration); iteration);
return Changelog.of(module, toTickets(module, ticketRefs)); Changelog changelog = Changelog.of(module, toTickets(module, ticketRefs));
return String.format("%s %s%n%s", module.getModule().getProject().getFullName(), ArtifactVersion.of(module),
changelog.toString(false, " "));
}
}).stream() // return ExecutionUtils
.map(changelog -> { .runAndReturn(executor, iteration, module -> changelog(iteration, module.getModule().getProject().getName())) //
.stream() //
ModuleIteration module = changelog.getModule();
return String.format("%s %s%n%s", module.getModule().getProject().getFullName(), ArtifactVersion.of(module),
changelog.toString(false, " "));
}) //
.collect(Collectors.joining("\n")); .collect(Collectors.joining("\n"));
} }

View File

@@ -138,22 +138,29 @@ class IssueTrackerCommands extends TimedCommand {
@CliCommand("tracker open-tickets") @CliCommand("tracker open-tickets")
public String openTickets(@CliOption(key = "", mandatory = true) TrainIteration iteration, // public String openTickets(@CliOption(key = "", mandatory = true) TrainIteration iteration, //
@CliOption(key = "module") String moduleName) { @CliOption(key = "module") String moduleName,
@CliOption(key = "filter-release-tickets") Boolean filterReleaseTickets) {
if (StringUtils.hasText(moduleName)) { if (StringUtils.hasText(moduleName)) {
Project project = Projects.requiredByName(moduleName); Project project = Projects.requiredByName(moduleName);
ModuleIteration module = iteration.getModule(project); ModuleIteration module = iteration.getModule(project);
String tickets = getTrackerFor(module).getTicketsFor(module).stream().filter(it -> !it.isResolved())
.collect(Tickets.toTicketsCollector()).toString(false);
return String.format("%s - %s%n%s%n", project.getFullName(), module.getFullVersionString(), tickets); return getTrackerFor(module).getTicketsFor(module) //
.stream() //
.filter(it -> !it.isResolved()
&& ((filterReleaseTickets == null || !filterReleaseTickets) || !it.isReleaseTicket())) //
.collect(Tickets.toTicketsCollector()) //
.toString(false);
} }
return ExecutionUtils.runAndReturn(executor, iteration, return ExecutionUtils.runAndReturn(executor, iteration,
moduleIteration -> openTickets(iteration, moduleIteration.getModule().getProject().getName())).// moduleIteration -> openTickets(iteration, moduleIteration.getModule().getProject().getName(),
stream().collect(Collectors.joining("\n")); filterReleaseTickets))
.stream() //
.filter(StringUtils::hasText) //
.collect(Collectors.joining("\n"));
} }
@CliCommand("tracker close") @CliCommand("tracker close")