Skip to content
Permalink
Browse files
964: Should only consider Fixed bugs for hgupdate-sync
Reviewed-by: kcr, erikj
  • Loading branch information
rwestberg committed Apr 13, 2021
1 parent cd6a10f commit 995a85849484b86553a6bd10d817de2ae86abfaa
@@ -43,9 +43,9 @@ void removeLabelForApprovedCSR(TestInfo testInfo) throws IOException {
var issues = credentials.getIssueProject();
var issue = issues.createIssue("This is an issue", List.of(), Map.of());

var csr = issues.createIssue("This is an approved CSR", List.of(), Map.of("resolution",
JSON.object().put("name", "Approved")));
var csr = issues.createIssue("This is an approved CSR", List.of(), Map.of());
csr.setState(Issue.State.CLOSED);
csr.setProperty("resolution", JSON.object().put("name", "Approved"));
issue.addLink(Link.create(csr, "csr for").build());

var bot = new CSRBot(repo, issues);
@@ -105,9 +105,9 @@ void alreadyApprovedCSR(TestInfo testInfo) throws IOException {
var issues = credentials.getIssueProject();
var issue = issues.createIssue("This is an issue", List.of(), Map.of());

var csr = issues.createIssue("This is an approved CSR", List.of(), Map.of("resolution",
JSON.object().put("name", "Approved")));
var csr = issues.createIssue("This is an approved CSR", List.of(), Map.of());
csr.setState(Issue.State.CLOSED);
csr.setProperty("resolution", JSON.object().put("name", "Approved"));
issue.addLink(Link.create(csr, "csr for").build());

var censusBuilder = credentials.getCensusBuilder()
@@ -192,14 +192,34 @@ public static Optional<Issue> findIssue(Issue primary, JdkVersion fixVersion) {
return Optional.empty();
}

public static List<Issue> findBackports(Issue primary, boolean resolvedOnly) {
private static boolean isFixed(Issue issue) {
if (issue.state() == Issue.State.OPEN) {
return false;
}
var resolution = issue.properties().get("resolution");
if (resolution == null || resolution.isNull()) {
return false;
}
var name = resolution.get("name");
if (name == null || name.isNull()) {
return false;
}

if (!name.asString().equals("Fixed")) {
return false;
}

return true;
}

public static List<Issue> findBackports(Issue primary, boolean fixedOnly) {
var links = primary.links();
return links.stream()
.filter(l -> l.issue().isPresent())
.filter(l -> l.relationship().isPresent())
.filter(l -> l.relationship().get().equals("backported by"))
.map(l -> l.issue().get())
.filter(i -> !resolvedOnly || (i.state() != Issue.State.OPEN))
.filter(i -> !fixedOnly || isFixed(i))
.filter(i -> i.properties().containsKey("issuetype"))
.filter(i -> i.properties().get("issuetype").asString().equals("Backport"))
.collect(Collectors.toList());
@@ -185,6 +185,10 @@ private static class BackportManager {
private void setState(Issue issue, String version) {
if (version.endsWith("#open")) {
version = version.substring(0, version.length() - 5);
} else if (version.endsWith("#wontfix")) {
version = version.substring(0, version.length() - 8);
issue.setState(Issue.State.RESOLVED);
issue.setProperty("resolution", JSON.object().put("name", JSON.of("Won't Fix")));
} else {
issue.setState(Issue.State.RESOLVED);
}
@@ -754,4 +758,15 @@ void sampleTest24(TestInfo testInfo) throws IOException {
backports.assertLabeled();
}
}

@Test
void wontFix(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "14");
backports.assertLabeled();

backports.addBackports("15", "13.0.7", "11.0.12-oracle", "11.0.11-oracle#wontfix", "11.0.10");
backports.assertLabeled("15");
}
}
}
@@ -24,7 +24,7 @@

import org.openjdk.skara.host.HostUser;
import org.openjdk.skara.issuetracker.*;
import org.openjdk.skara.json.JSONValue;
import org.openjdk.skara.json.*;
import org.openjdk.skara.network.URIBuilder;

import java.net.URI;
@@ -150,6 +150,7 @@ public void setState(State state) {
data.state = state;
data.lastUpdate = ZonedDateTime.now();
data.closedBy = user;
data.properties.put("resolution", JSON.object().put("name", JSON.of("Fixed")));
}

@Override

1 comment on commit 995a858

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 995a858 Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.