Remove any dependency upgrades that have been superseded
diff --git a/src/main/java/org/apache/openejb/tools/release/cmd/ReleaseNotes.java b/src/main/java/org/apache/openejb/tools/release/cmd/ReleaseNotes.java
index 0867223..8164729 100644
--- a/src/main/java/org/apache/openejb/tools/release/cmd/ReleaseNotes.java
+++ b/src/main/java/org/apache/openejb/tools/release/cmd/ReleaseNotes.java
@@ -18,6 +18,8 @@
import com.atlassian.jira.rest.client.api.SearchRestClient;
import com.atlassian.jira.rest.client.api.domain.Issue;
+import com.atlassian.jira.rest.client.api.domain.IssueLink;
+import com.atlassian.jira.rest.client.api.domain.IssueLinkType;
import com.atlassian.jira.rest.client.api.domain.IssueType;
import com.atlassian.jira.rest.client.api.domain.SearchResult;
import lombok.Getter;
@@ -32,6 +34,7 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@@ -42,6 +45,9 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import static com.atlassian.jira.rest.client.api.domain.IssueLinkType.Direction.INBOUND;
+import static com.atlassian.jira.rest.client.api.domain.IssueLinkType.Direction.OUTBOUND;
+
/**
* @version $Rev$ $Date$
*/
@@ -117,9 +123,10 @@
out.println();
out.printf("== %s%n", section.getName());
out.println();
+ out.println("[.compact]");
if (section.getName().equals("Dependency upgrade")) {
- issues.stream()
+ removeSuperseded(issues).stream()
.map(Upgrade::new)
.sorted(Comparator.comparing(Upgrade::getSummary))
.forEach(upgrade -> {
@@ -141,6 +148,23 @@
};
}
+ public static Collection<Issue> removeSuperseded(final List<Issue> issues) {
+ final Map<String, Issue> map = new HashMap<>();
+ issues.forEach(issue -> map.put(issue.getKey(), issue));
+
+ for (final Issue issue : issues) {
+ for (final IssueLink link : issue.getIssueLinks()) {
+ final IssueLinkType linkType = link.getIssueLinkType();
+ if (!"Supercedes".equalsIgnoreCase(linkType.getName())) continue;
+ if (!OUTBOUND.equals(linkType.getDirection())) continue;
+
+ map.remove(link.getTargetIssueKey());
+ }
+ }
+
+ return map.values();
+ }
+
public static void main(final String[] args) throws Throwable {
final List<String> argsList = new ArrayList<String>();