Skip to content

Commit 29cbb40

Browse files
committed
Automatically exclude [bot] contributors from the changelog
Closes gh-102
1 parent b77d3f2 commit 29cbb40

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

README.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ changelog:
170170

171171
=== Excluding Contributors
172172

173-
If you have contributors that you don't want to thank (perhaps core team members or bots), you can set the following:
173+
Contributors whose username ends with `[bot]`, such as `dependabot[bot]` and `github-actions[bot]`, are automatically excluded.
174+
If you have other contributors that you want to be excluded (perhaps core team members), you can set the following:
174175

175176
[source,yaml]
176177
----
177178
changelog:
178179
contributors:
179180
exclude:
180-
names: ["dependabot"]
181+
names: ["coremember"]
181182
----
182183

183184
You can also use `*` if you want to drop the contributors section entirely.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ private Issue getPortedReferenceIssue(Issue issue) {
202202
}
203203

204204
private boolean isIncludedContributor(User user) {
205-
return !this.excludeContributors.contains(user.getName());
205+
String name = user.getName();
206+
return !this.excludeContributors.contains(name) && !name.endsWith("[bot]");
206207
}
207208

208209
private void addContributorsContent(StringBuilder content, Set<User> contributors) {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ void generateWhenMoreThanTwoContributors() throws Exception {
190190
assertChangelog("23").hasContent(from("output-with-more-than-two-contributors"));
191191
}
192192

193+
@Test
194+
void generateWhenHasBotContributors() throws Exception {
195+
User contributor1 = createUser("dependabot[bot]");
196+
User contributor2 = createUser("github-actions[bot]");
197+
User contributor3 = createUser("contributor");
198+
List<Issue> issues = new ArrayList<>();
199+
issues.add(newPullRequest("Enhancement 1", "1", Type.ENHANCEMENT, "enhancement-1-url", contributor1));
200+
issues.add(newPullRequest("Enhancement 2", "2", Type.ENHANCEMENT, "enhancement-2-url", contributor2));
201+
issues.add(newPullRequest("Enhancement 3", "3", Type.ENHANCEMENT, "enhancement-3-url", contributor3));
202+
given(this.service.getIssuesForMilestone(23, REPO)).willReturn(issues);
203+
assertChangelog("23").hasContent(from("output-with-bot-contributors"));
204+
}
205+
193206
@Test
194207
void generateWhenNoIgnoredLabels() throws Exception {
195208
User contributor1 = createUser("contributor1");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## :star: New Features
2+
3+
- Enhancement 1 [#1](enhancement-1-url)
4+
- Enhancement 2 [#2](enhancement-2-url)
5+
- Enhancement 3 [#3](enhancement-3-url)
6+
7+
## :heart: Contributors
8+
9+
Thank you to all the contributors who worked on this release:
10+
11+
@contributor

0 commit comments

Comments
 (0)