diff --git a/README.adoc b/README.adoc index d7a2b16..7fadbd6 100644 --- a/README.adoc +++ b/README.adoc @@ -170,14 +170,15 @@ changelog: === Excluding Contributors -If you have contributors that you don't want to thank (perhaps core team members or bots), you can set the following: +Contributors whose username ends with `[bot]`, such as `dependabot[bot]` and `github-actions[bot]`, are automatically excluded. +If you have other contributors that you want to be excluded (perhaps core team members), you can set the following: [source,yaml] ---- changelog: contributors: exclude: - names: ["dependabot"] + names: ["coremember"] ---- You can also use `*` if you want to drop the contributors section entirely. diff --git a/src/main/java/io/spring/githubchangeloggenerator/ChangelogGenerator.java b/src/main/java/io/spring/githubchangeloggenerator/ChangelogGenerator.java index 8e29a86..277040d 100644 --- a/src/main/java/io/spring/githubchangeloggenerator/ChangelogGenerator.java +++ b/src/main/java/io/spring/githubchangeloggenerator/ChangelogGenerator.java @@ -202,7 +202,8 @@ private Issue getPortedReferenceIssue(Issue issue) { } private boolean isIncludedContributor(User user) { - return !this.excludeContributors.contains(user.getName()); + String name = user.getName(); + return !this.excludeContributors.contains(name) && !name.endsWith("[bot]"); } private void addContributorsContent(StringBuilder content, Set contributors) { diff --git a/src/test/java/io/spring/githubchangeloggenerator/ChangelogGeneratorTests.java b/src/test/java/io/spring/githubchangeloggenerator/ChangelogGeneratorTests.java index 235f219..dbe2e65 100644 --- a/src/test/java/io/spring/githubchangeloggenerator/ChangelogGeneratorTests.java +++ b/src/test/java/io/spring/githubchangeloggenerator/ChangelogGeneratorTests.java @@ -190,6 +190,19 @@ void generateWhenMoreThanTwoContributors() throws Exception { assertChangelog("23").hasContent(from("output-with-more-than-two-contributors")); } + @Test + void generateWhenHasBotContributors() throws Exception { + User contributor1 = createUser("dependabot[bot]"); + User contributor2 = createUser("github-actions[bot]"); + User contributor3 = createUser("contributor"); + List issues = new ArrayList<>(); + issues.add(newPullRequest("Enhancement 1", "1", Type.ENHANCEMENT, "enhancement-1-url", contributor1)); + issues.add(newPullRequest("Enhancement 2", "2", Type.ENHANCEMENT, "enhancement-2-url", contributor2)); + issues.add(newPullRequest("Enhancement 3", "3", Type.ENHANCEMENT, "enhancement-3-url", contributor3)); + given(this.service.getIssuesForMilestone(23, REPO)).willReturn(issues); + assertChangelog("23").hasContent(from("output-with-bot-contributors")); + } + @Test void generateWhenNoIgnoredLabels() throws Exception { User contributor1 = createUser("contributor1"); diff --git a/src/test/resources/io/spring/githubchangeloggenerator/output-with-bot-contributors b/src/test/resources/io/spring/githubchangeloggenerator/output-with-bot-contributors new file mode 100644 index 0000000..9f7012e --- /dev/null +++ b/src/test/resources/io/spring/githubchangeloggenerator/output-with-bot-contributors @@ -0,0 +1,11 @@ +## :star: New Features + +- Enhancement 1 [#1](enhancement-1-url) +- Enhancement 2 [#2](enhancement-2-url) +- Enhancement 3 [#3](enhancement-3-url) + +## :heart: Contributors + +Thank you to all the contributors who worked on this release: + +@contributor