Skip to content

Commit

Permalink
fix(changelog): Remove bots in regex search
Browse files Browse the repository at this point in the history
  • Loading branch information
Sironheart authored and aalmiray committed Oct 27, 2022
1 parent 39f7c7b commit ca6f2ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Expand Up @@ -49,7 +49,6 @@
import static java.util.stream.Collectors.toSet;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;
import static org.jreleaser.util.StringUtils.toSafeRegexPattern;

/**
* @author Andres Almiray
Expand Down Expand Up @@ -940,7 +939,7 @@ public boolean containsContributor(String name) {
if (isNotBlank(name)) {
String n = name.trim();
for (String contributor : contributors) {
if (n.contains(contributor) || n.matches(toSafeRegexPattern(contributor))) {
if (n.contains(contributor) || n.matches(contributor)) {
return true;
}
}
Expand Down
Expand Up @@ -52,7 +52,9 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static java.util.stream.Collectors.toList;
import static org.mockito.ArgumentMatchers.anyBoolean;
Expand Down Expand Up @@ -115,6 +117,27 @@ public void notParsable() throws GitAPIException, IOException {
verify(logCommand).add(headId);
}

@Test
@DisplayName("Should exclude bot commits from changelog")
public void excludeBots() throws IOException {
Changelog.Hide instance = new Changelog.Hide();
Set<String> contributors = new HashSet<>();
contributors.add("dependabot");
contributors.add("liquibot");
contributors.add("randombot");
contributors.add("aalmiray");
contributors.add("sironheart");
instance.addContributors(contributors);

if (instance.containsContributor("depend") ||
instance.containsContributor("bot") ||
instance.containsContributor("random") ||
instance.containsContributor("liqui")
) {
throw new IOException("Should exclude bots");
}
}

@Test
@DisplayName("When no tag is found that match current configured tag name then all commits from head must be used")
public void tagThatNoMatches() throws GitAPIException, IOException {
Expand Down

0 comments on commit ca6f2ab

Please sign in to comment.