Skip to content

Commit

Permalink
[closes #452] Add breaking changes to changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
avano committed Apr 19, 2023
1 parent 8e7cda1 commit cddc3f7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
44 changes: 43 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<okhttp-version>4.10.0</okhttp-version>
<failsafe-version>3.3.0</failsafe-version>
<gson-version>2.10</gson-version>
<nashorn.version>15.4</nashorn.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -320,13 +321,19 @@
</profile>
<profile>
<id>changelog</id>

<build>
<plugins>
<plugin>
<groupId>se.bjurr.gitchangelog</groupId>
<artifactId>git-changelog-maven-plugin</artifactId>
<version>${git.changelog.maven.plugin}</version>
<dependencies>
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>${nashorn.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>GenerateGitChangelog</id>
Expand All @@ -338,6 +345,41 @@
<templateBaseDir>templates</templateBaseDir>
<templateFile>templates/changelog.mustache</templateFile>
<ignoreCommitsIfMessageMatches>(Merge (pull request|branch).*)|(\[BOM\] Sync .*)</ignoreCommitsIfMessageMatches>
<javascriptHelper>
<![CDATA[
Handlebars.registerHelper('printBreakingChanges', function(commits) {
let marker = "breaking: "
let msg = ""
for (let i = 0; i < commits.length; i++) {
let commit = commits[i];
let idx = commit.messageBody.indexOf(marker);
if (idx !== -1) {
let end = commit.messageBody.indexOf("\n", idx);
if (end == -1) {
end = commit.messageBody.length
}
msg += "- " + commit.messageBody.substring(idx + marker.length, end) + " " + Handlebars.helpers.createCommitLink(commit.hash) + "\n";
}
}
if (msg.trim()) {
msg = "## Breaking changes\n\n" + msg + "\n";
}
return msg;
});
Handlebars.registerHelper('createCommitLink', function(hash) {
return "[[" + hash + "](https://github.com/tnb-software/TNB/commit/" + hash + ")]";
});
Handlebars.registerHelper('printCommit', function(commit) {
return "- **" + commit.messageTitle + "** by " + commit.authorName + " " + Handlebars.helpers.createCommitLink(commit.hash) + "\n";
});
]]>
</javascriptHelper>
</configuration>
</execution>
</executions>
Expand Down
16 changes: 8 additions & 8 deletions templates/changelog.mustache
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{{#printBreakingChanges commits}}{{/printBreakingChanges}}
## What's Changed

{{#commits}}
{{#ifMatches messageTitle ".*[bB]ump .*"}}{{else}}
{{>commit}}

{{/ifMatches}}
{{#ifMatches messageTitle ".*[bB]ump .*"}}
{{else}}
{{#printCommit .}}{{/printCommit}}
{{/ifMatches}}
{{/commits}}

## Dependency updates

{{#commits}}
{{#ifMatches messageTitle ".*[bB]ump .*"}}
{{>commit}}

{{/ifMatches}}
{{#ifMatches messageTitle ".*[bB]ump .*"}}
{{#printCommit .}}{{/printCommit}}
{{/ifMatches}}
{{/commits}}
1 change: 0 additions & 1 deletion templates/commit

This file was deleted.

0 comments on commit cddc3f7

Please sign in to comment.