mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[changelog] accept regex: prefix in labeler's label. Resolves #386
This commit is contained in:
@@ -67,6 +67,7 @@ import static org.jreleaser.util.StringUtils.toSafeRegexPattern;
|
|||||||
*/
|
*/
|
||||||
public class ChangelogGenerator {
|
public class ChangelogGenerator {
|
||||||
private static final String UNCATEGORIZED = "<<UNCATEGORIZED>>";
|
private static final String UNCATEGORIZED = "<<UNCATEGORIZED>>";
|
||||||
|
private static final String REGEX_PREFIX = "regex:";
|
||||||
|
|
||||||
public static String generate(JReleaserContext context) throws IOException {
|
public static String generate(JReleaserContext context) throws IOException {
|
||||||
if (!context.getModel().getRelease().getGitService().getChangelog().isEnabled()) {
|
if (!context.getModel().getRelease().getGitService().getChangelog().isEnabled()) {
|
||||||
@@ -413,13 +414,25 @@ public class ChangelogGenerator {
|
|||||||
private static void applyLabels(Commit commit, Set<Changelog.Labeler> labelers) {
|
private static void applyLabels(Commit commit, Set<Changelog.Labeler> labelers) {
|
||||||
for (Changelog.Labeler labeler : labelers) {
|
for (Changelog.Labeler labeler : labelers) {
|
||||||
if (isNotBlank(labeler.getTitle())) {
|
if (isNotBlank(labeler.getTitle())) {
|
||||||
if (commit.title.contains(labeler.getTitle()) || commit.title.matches(toSafeRegexPattern(labeler.getTitle()))) {
|
if (labeler.getTitle().startsWith(REGEX_PREFIX)) {
|
||||||
commit.labels.add(labeler.getLabel());
|
if (commit.title.matches(labeler.getTitle().substring(REGEX_PREFIX.length()))) {
|
||||||
|
commit.labels.add(labeler.getLabel());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (commit.title.contains(labeler.getTitle()) || commit.title.matches(toSafeRegexPattern(labeler.getTitle()))) {
|
||||||
|
commit.labels.add(labeler.getLabel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isNotBlank(labeler.getBody())) {
|
if (isNotBlank(labeler.getBody())) {
|
||||||
if (commit.body.contains(labeler.getBody()) || commit.body.matches(toSafeRegexPattern(labeler.getBody()))) {
|
if (labeler.getTitle().startsWith(REGEX_PREFIX)) {
|
||||||
commit.labels.add(labeler.getLabel());
|
if (commit.body.matches(labeler.getBody().substring(REGEX_PREFIX.length()))) {
|
||||||
|
commit.labels.add(labeler.getLabel());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (commit.body.contains(labeler.getBody()) || commit.body.matches(toSafeRegexPattern(labeler.getBody()))) {
|
||||||
|
commit.labels.add(labeler.getLabel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user