-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve changelog rendering template
- Loading branch information
1 parent
b17f74d
commit 713947d
Showing
6 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/extension.js | ||
tailwind.config.js | ||
webpack.config.js | ||
changelog-setup.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/extension.js | ||
|
||
/changelog-template.hbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module.exports = function (Handlebars) { | ||
Handlebars.registerHelper('full-commit-list', (commits, merges, fixes, options) => { | ||
commits = commits | ||
.concat(merges.map((merge) => merge.commit)) | ||
.concat(fixes.map((fix) => fix.commit)); | ||
|
||
if (!commits || commits.length === 0) { | ||
return ''; | ||
} | ||
|
||
const { exclude, message, subject, heading } = options.hash; | ||
|
||
const list = commits | ||
.filter((item) => { | ||
const commit = item.commit || item; | ||
|
||
// Exclude commits where subject includes with "Release v" | ||
if (commit.subject.includes('Release v')) { | ||
return false; | ||
} | ||
|
||
if (exclude) { | ||
const excludeList = exclude.split('|'); | ||
for (const e of excludeList) { | ||
const pattern = new RegExp(e, 'm'); | ||
if (pattern.test(commit.message)) { | ||
return false; | ||
} | ||
} | ||
} | ||
if (message) { | ||
const pattern = new RegExp(message, 'm'); | ||
return pattern.test(commit.message); | ||
} | ||
if (subject) { | ||
const pattern = new RegExp(subject); | ||
const match = pattern.test(commit.subject); | ||
if (match) { | ||
// remove the message from the commit subject and message and trim | ||
commit.subject = commit.subject.replace(pattern, '').trim(); | ||
} | ||
return match; | ||
} | ||
return true; | ||
}) | ||
.map((item) => options.fn(item)) | ||
.join(''); | ||
|
||
if (!list) { | ||
return ''; | ||
} | ||
|
||
if (!heading) { | ||
return list; | ||
} | ||
|
||
return `${heading}\n\n${list}`; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
### Changelog | ||
|
||
#### All notable changes to this project will be documented in this file. | ||
|
||
Generated by the awesome [`auto-changelog`](https://github.com/CookPete/auto-changelog) package 👏🏽. | ||
|
||
{{#each releases}} | ||
{{#if href}} | ||
## [{{title}}]({{href}}){{#if tag}} - {{niceDate}}{{/if}} | ||
{{else}} | ||
## {{title}}{{#if tag}} - {{isoDate}}{{/if}} | ||
{{/if}} | ||
{{#if summary}} | ||
{{summary}} | ||
{{/if}} | ||
|
||
{{#full-commit-list commits merges fixes heading='### Breaking Changes' subject='Breaking change: '}} | ||
- {{subject}} [`{{shorthash}}`]({{href}}) | ||
{{/full-commit-list}} | ||
|
||
{{#full-commit-list commits merges fixes heading='### New Features' subject='Feat:' exclude='Breaking change: '}} | ||
- {{subject}} [`{{shorthash}}`]({{href}}) | ||
{{/full-commit-list}} | ||
|
||
{{#full-commit-list commits merges fixes heading='### Bug Fixes' subject='Bug Fix:' exclude='Breaking change: '}} | ||
- {{subject}} [`{{shorthash}}`]({{href}}) | ||
{{/full-commit-list}} | ||
|
||
{{#full-commit-list commits merges fixes heading='### Other Changes' exclude='Feat:|Bug Fix:|Breaking change:'}} | ||
- {{subject}} [`{{shorthash}}`]({{href}}) | ||
{{/full-commit-list}} | ||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters