Link to release notes from upgrade issues
Closes gh-31544
This commit is contained in:
parent
77fa968209
commit
42ce97b40f
|
@ -146,8 +146,12 @@ public class Library {
|
|||
}
|
||||
|
||||
public Map<String, String> getLinks() {
|
||||
return getLinks(this.version);
|
||||
}
|
||||
|
||||
public Map<String, String> getLinks(LibraryVersion version) {
|
||||
Map<String, String> links = new TreeMap<>();
|
||||
this.links.forEach((name, linkFactory) -> links.put(name, linkFactory.apply(this.version)));
|
||||
this.links.forEach((name, linkFactory) -> links.put(name, linkFactory.apply(version)));
|
||||
return Collections.unmodifiableMap(links);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.build.bom.bomr;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiPredicate;
|
||||
|
@ -32,6 +33,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.boot.build.bom.BomExtension;
|
||||
import org.springframework.boot.build.bom.Library;
|
||||
import org.springframework.boot.build.bom.bomr.ReleaseSchedule.Release;
|
||||
import org.springframework.boot.build.bom.bomr.github.Issue;
|
||||
import org.springframework.boot.build.bom.bomr.github.Milestone;
|
||||
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
|
||||
import org.springframework.boot.build.properties.BuildProperties;
|
||||
|
@ -67,20 +69,33 @@ public abstract class MoveToSnapshots extends UpgradeDependencies {
|
|||
|
||||
@Override
|
||||
protected String issueTitle(Upgrade upgrade) {
|
||||
return "Upgrade to " + description(upgrade);
|
||||
}
|
||||
|
||||
private String description(Upgrade upgrade) {
|
||||
String snapshotVersion = upgrade.getVersion().toString();
|
||||
String releaseVersion = snapshotVersion.substring(0, snapshotVersion.length() - "-SNAPSHOT".length());
|
||||
return "Upgrade to " + upgrade.getLibrary().getName() + " " + releaseVersion;
|
||||
return upgrade.getLibrary().getName() + " " + releaseVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String issueBody(Upgrade upgrade, Issue existingUpgrade) {
|
||||
String releaseNotes = upgrade.getLibrary().getLinks().get("releaseNotes");
|
||||
List<String> lines = new ArrayList<>();
|
||||
String description = description(upgrade);
|
||||
if (releaseNotes != null) {
|
||||
lines.add("Upgrade to [%s](%s).".formatted(description, releaseNotes));
|
||||
}
|
||||
lines.add("Upgrade to %s.".formatted(description));
|
||||
if (existingUpgrade != null) {
|
||||
lines.add("Supersedes #" + existingUpgrade.getNumber());
|
||||
}
|
||||
return String.join("\\r\\n\\r\\n", lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String commitMessage(Upgrade upgrade, int issueNumber) {
|
||||
return "Start building against " + upgrade.getLibrary().getName() + " " + releaseVersion(upgrade) + " snapshots"
|
||||
+ "\n\nSee gh-" + issueNumber;
|
||||
}
|
||||
|
||||
private String releaseVersion(Upgrade upgrade) {
|
||||
String snapshotVersion = upgrade.getVersion().toString();
|
||||
return snapshotVersion.substring(0, snapshotVersion.length() - "-SNAPSHOT".length());
|
||||
return "Start building against " + description(upgrade) + " snapshots" + "\n\nSee gh-" + issueNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.springframework.boot.build.bom.bomr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gradle.api.Task;
|
||||
|
@ -24,6 +27,8 @@ import org.gradle.api.artifacts.dsl.RepositoryHandler;
|
|||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
|
||||
|
||||
import org.springframework.boot.build.bom.BomExtension;
|
||||
import org.springframework.boot.build.bom.Library.LibraryVersion;
|
||||
import org.springframework.boot.build.bom.bomr.github.Issue;
|
||||
import org.springframework.boot.build.properties.BuildProperties;
|
||||
|
||||
/**
|
||||
|
@ -68,4 +73,23 @@ public abstract class UpgradeBom extends UpgradeDependencies {
|
|||
return issueTitle(upgrade) + "\n\nCloses gh-" + issueNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String issueBody(Upgrade upgrade, Issue existingUpgrade) {
|
||||
String releaseNotes = upgrade.getLibrary()
|
||||
.getLinks(new LibraryVersion(upgrade.getVersion()))
|
||||
.get("releaseNotes");
|
||||
List<String> lines = new ArrayList<>();
|
||||
String description = upgrade.getLibrary().getName() + " " + upgrade.getVersion();
|
||||
if (releaseNotes != null) {
|
||||
lines.add("Upgrade to [%s](%s).".formatted(description, releaseNotes));
|
||||
}
|
||||
else {
|
||||
lines.add("Upgrade to %s.".formatted(description));
|
||||
}
|
||||
if (existingUpgrade != null) {
|
||||
lines.add("Supersedes #" + existingUpgrade.getNumber());
|
||||
}
|
||||
return String.join("\\r\\n\\r\\n", lines);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -119,11 +119,12 @@ public abstract class UpgradeDependencies extends DefaultTask {
|
|||
System.out.println("");
|
||||
for (Upgrade upgrade : upgrades) {
|
||||
System.out.println(upgrade.getLibrary().getName() + " " + upgrade.getVersion());
|
||||
String title = issueTitle(upgrade);
|
||||
Issue existingUpgradeIssue = findExistingUpgradeIssue(existingUpgradeIssues, upgrade);
|
||||
try {
|
||||
Path modified = this.upgradeApplicator.apply(upgrade);
|
||||
int issueNumber = getOrOpenUpgradeIssue(repository, issueLabels, milestone, title,
|
||||
String title = issueTitle(upgrade);
|
||||
String body = issueBody(upgrade, existingUpgradeIssue);
|
||||
int issueNumber = getOrOpenUpgradeIssue(repository, issueLabels, milestone, title, body,
|
||||
existingUpgradeIssue);
|
||||
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.CLOSED) {
|
||||
existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
|
||||
|
@ -151,11 +152,10 @@ public abstract class UpgradeDependencies extends DefaultTask {
|
|||
}
|
||||
|
||||
private int getOrOpenUpgradeIssue(GitHubRepository repository, List<String> issueLabels, Milestone milestone,
|
||||
String title, Issue existingUpgradeIssue) {
|
||||
String title, String body, Issue existingUpgradeIssue) {
|
||||
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.OPEN) {
|
||||
return existingUpgradeIssue.getNumber();
|
||||
}
|
||||
String body = (existingUpgradeIssue != null) ? "Supersedes #" + existingUpgradeIssue.getNumber() : "";
|
||||
return repository.openIssue(title, body, issueLabels, milestone);
|
||||
}
|
||||
|
||||
|
@ -289,4 +289,6 @@ public abstract class UpgradeDependencies extends DefaultTask {
|
|||
|
||||
protected abstract String commitMessage(Upgrade upgrade, int issueNumber);
|
||||
|
||||
protected abstract String issueBody(Upgrade upgrade, Issue existingUpgrade);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue