Skip to content

Commit

Permalink
Automatically exclude [bot] contributors from the changelog
Browse files Browse the repository at this point in the history
Closes gh-102
  • Loading branch information
wilkinsona committed Jun 21, 2024
1 parent b77d3f2 commit 29cbb40
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<User> contributors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Issue> 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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 29cbb40

Please sign in to comment.