Skip to content

Commit 29715a8

Browse files
committed
Tolerate ported issue without a body
Closes gh-114
1 parent 2cb10d1 commit 29715a8

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/main/java/io/spring/githubchangeloggenerator/ChangelogGenerator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2024 the original author or authors.
2+
* Copyright 2018-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232

3333
import org.springframework.stereotype.Component;
3434
import org.springframework.util.FileCopyUtils;
35+
import org.springframework.util.StringUtils;
3536

3637
import io.spring.githubchangeloggenerator.ApplicationProperties.ExternalLink;
3738
import io.spring.githubchangeloggenerator.ApplicationProperties.IssueSort;
@@ -184,6 +185,9 @@ private Set<User> getContributors(List<Issue> issues) {
184185
}
185186

186187
private Issue getPortedReferenceIssue(Issue issue) {
188+
if (!StringUtils.hasText(issue.getBody())) {
189+
return issue;
190+
}
187191
for (PortedIssue portedIssue : this.portedIssues) {
188192
List<String> labelNames = issue.getLabels().stream().map(Label::getName).toList();
189193
if (labelNames.contains(portedIssue.getLabel())) {

src/test/java/io/spring/githubchangeloggenerator/ChangelogGeneratorTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ void generateWhenHasForwardAndBackPorts() throws Exception {
135135
assertChangelog("23").hasContent(from("output-with-no-bugs"));
136136
}
137137

138+
@Test
139+
void generateWhenHasPortedIssuesWithNoBody() throws Exception {
140+
List<Issue> issues = new ArrayList<>();
141+
issues.add(newPortedIssue("Enhancement 1", "2", null, "enhancement-1-url", Type.FORWARD_PORT));
142+
issues.add(newPortedIssue("Enhancement 2", "4", null, "enhancement-2-url", Type.BACK_PORT));
143+
given(this.service.getIssuesForMilestone(23, REPO)).willReturn(issues);
144+
assertChangelog("23").content().isEqualTo(from("output-with-ported-issues-without-a-body"));
145+
}
146+
138147
@Test
139148
void generateWhenHasExcludedContributors() throws Exception {
140149
User contributor1 = createUser("contributor1");
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## :star: New Features
2+
3+
- Enhancement 1 [#2](enhancement-1-url)
4+
- Enhancement 2 [#4](enhancement-2-url)

0 commit comments

Comments
 (0)