From 1647ce44e7dde2ac9c13d6630fb22df1473f029b Mon Sep 17 00:00:00 2001 From: Charlie Blundell Date: Thu, 2 Sep 2021 03:00:58 +1000 Subject: [PATCH 1/5] Add Template for handling commits with Conventional Commits format --- templates/conventionalcommits.hbs | 133 ++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 templates/conventionalcommits.hbs diff --git a/templates/conventionalcommits.hbs b/templates/conventionalcommits.hbs new file mode 100644 index 00000000..b3acfa53 --- /dev/null +++ b/templates/conventionalcommits.hbs @@ -0,0 +1,133 @@ +## Changelog + +{{!-- +Introduction +• This template tries to follow conventional commits format https://www.conventionalcommits.org/en/v1.0.0/ +• The template uses regex to filter commit types into their own headings (this is more than just fixes and features headings) +• It also uses the replaceText function in package.json to remove the commit type text from the message, because the headers are shown instead. + +• The text 'Breaking:' or 'Breaking changes:' can be located anywhere in the commit. +• The types feat:, fix:, chore:, docs:, refactor:, test:, style:, perf: must be at the beginning of the commit subject with an : on end. + • They can optionally have a scope set to outline the module or component that is affected eg feat(bldAssess): + +Example Definitions +• feat: A new feature +• fix: A bug fix +• perf: A code change that improves performance +• refactor: A code change that neither fixes a bug nor adds a feature +• style: Changes that do not affect the meaning of the code (white-space, formatting, spelling mistakes, missing semi-colons, etc) +• test: Adding missing tests or correcting existing tests +• docs: Adding/updating documentation +• chore: Something like updating a library version, or moving files to be in a better location and updating all file refs +--}} + + +{{!-- In package.json need to add this to remove label text from the change log output (becuase the markdown headers are now used to group them). + NOTES • Individual brackets have been escaped twice to be Json compliant. + • For items that define a scope eg feat(bldAssess): We remove the 1st bracket and then re-add it so we can select the right piece of text +{ + "name": "my-awesome-package", + + "auto-changelog": { + "replaceText": { + "([bB]reaking:)": "", + "([bB]reaking change:)": "", + "(^[fF]eat:)": "", + "(^[fF]eat\\()": "\\(", + "(^[fF]ix:)": "", + "(^[fF]ix\\()": "\\(", + "(^[cC]hore:)": "", + "(^[cC]hore\\()": "\\(", + "(^[dD]ocs:)": "", + "(^[dD]ocs\\()": "\\(", + "(^[rR]efactor:)": "", + "(^[rR]efactor\\()": "\\(", + "(^[tT]est:)": "", + "(^[tT]est\\()": "\\(", + "(^[sS]tyle:)": "", + "(^[sS]tyle\\()": "\\(", + "(^[pP]erf:)": "", + "(^[pP]erf\\()": "\\(" + } + } + +} + --}} + + {{!-- + Regex reminders + ^ = starts with + \( = ( character (otherwise it is interpreted as a regex lookup group) + * = zero or more of the previous character + \s = whitespace + . = any character except newline + | = or + [aA] = charcter a or character A + --}} + + +{{#each releases}} + {{#if href}} + ##{{#unless major}}#{{/unless}} [{{title}}]({{href}}) - {{#if tag}} {{niceDate}} {{/if}} + + {{else}} + ### {{title}} + {{/if}} + + + {{#if summary}} + {{summary}} + {{/if}} + + {{#each merges}} + - {{#if commit.breaking}}**Breaking change:** {{/if}}{{message}} + {{/each}} + + {{#each fixes}} + - {{#if commit.breaking}}**Breaking change:** {{/if}}{{commit.subject}}{{#each fixes}}{{/each}} + {{/each}} + + + {{! List commits with 'breaking:' or 'Breaking change:' anywhere in the message under a heading}} + {{#commit-list commits heading='#### Breaking Changes :warning:' message='[bB]reaking [cC]hange:|[bB]reaking:' }} + - {{subject}} @{{author}} + {{/commit-list}} + + {{! List commits organised under a heading, but not those already listed in the breaking section }} + {{#commit-list commits heading='#### New Features' message='^[fF]eat:|[fF]eat\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### Fixes' message='^[fF]ix:|^[fF]ix\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### Chores And Housekeeping' message='^[cC]hore:|^[cC]hore\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### Documentation Changes' message='^[dD]ocs:|^[dD]ocs\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### Refactoring and Updates' message='^[rR]efactor:|^[rR]efactor\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### Changes to Test Assests' message='^[tT]est:|^[tT]est\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### Tidying of Code eg Whitespace' message='^[sS]tyle:|^[sS]tyle\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### Performance Improvments' message='^[pP]erf:|^[pP]erf\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} + - {{subject}} @{{author}} + {{/commit-list}} + + {{#commit-list commits heading='#### General Changes' exclude='[bB]reaking [cC]hange:|[bB]reaking:|^[fF]eat:|^[fF]eat\(|^[fF]ix:|^[fF]ix\(|^[cC]hore:|^[cC]hore\(|^[dD]ocs:|^[dD]ocs\(|^[rR]efactor:|^[rR]efactor\(|^[tT]est:|^[tT]est\(|^[sS]tyle:|^[sS]tyle\(|^[pP]erf:|^[pP]erf\('}} + - {{subject}} @{{author}} + {{/commit-list}} + +{{/each}} From a6266b70b3c075b50233348688edaf59bf4cb8f2 Mon Sep 17 00:00:00 2001 From: Charlie Blundell Date: Wed, 9 Feb 2022 20:25:44 +1100 Subject: [PATCH 2/5] Add {{Author}} tag to readme example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 554592e0..15db5406 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ My custom changelog template. Don’t worry about indentation here; it is automa - Each fix has a {{commit}} with a {{commit.subject}}, an {{id}} and a {{href}} to the fixed issue. {{/each}} {{#each commits}} - - Commits have a {{shorthash}}, a {{subject}} and a {{href}}, amongst other things. + - Commits have a {{shorthash}}, a {{subject}} and a {{href}}, {{author}} amongst other things. {{/each}} {{/each}} ``` From 413c384382bd220eb1a2be326c005002e2a1d02e Mon Sep 17 00:00:00 2001 From: Charlie Blundell Date: Wed, 9 Feb 2022 20:46:53 +1100 Subject: [PATCH 3/5] Added shorthash to template --- templates/conventionalcommits.hbs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/templates/conventionalcommits.hbs b/templates/conventionalcommits.hbs index b3acfa53..5f9df34b 100644 --- a/templates/conventionalcommits.hbs +++ b/templates/conventionalcommits.hbs @@ -9,6 +9,7 @@ Introduction • The text 'Breaking:' or 'Breaking changes:' can be located anywhere in the commit. • The types feat:, fix:, chore:, docs:, refactor:, test:, style:, perf: must be at the beginning of the commit subject with an : on end. • They can optionally have a scope set to outline the module or component that is affected eg feat(bldAssess): +• There is a short hash on the end of every commit that is currently commented out so that change log did not grow too long (due to some system's file size limitations). You can uncomment if you wish [`{{shorthash}}`]({{href}}) Example Definitions • feat: A new feature @@ -95,39 +96,39 @@ Example Definitions {{! List commits organised under a heading, but not those already listed in the breaking section }} {{#commit-list commits heading='#### New Features' message='^[fF]eat:|[fF]eat\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### Fixes' message='^[fF]ix:|^[fF]ix\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### Chores And Housekeeping' message='^[cC]hore:|^[cC]hore\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### Documentation Changes' message='^[dD]ocs:|^[dD]ocs\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### Refactoring and Updates' message='^[rR]efactor:|^[rR]efactor\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### Changes to Test Assests' message='^[tT]est:|^[tT]est\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### Tidying of Code eg Whitespace' message='^[sS]tyle:|^[sS]tyle\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### Performance Improvments' message='^[pP]erf:|^[pP]erf\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{#commit-list commits heading='#### General Changes' exclude='[bB]reaking [cC]hange:|[bB]reaking:|^[fF]eat:|^[fF]eat\(|^[fF]ix:|^[fF]ix\(|^[cC]hore:|^[cC]hore\(|^[dD]ocs:|^[dD]ocs\(|^[rR]efactor:|^[rR]efactor\(|^[tT]est:|^[tT]est\(|^[sS]tyle:|^[sS]tyle\(|^[pP]erf:|^[pP]erf\('}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{/commit-list}} {{/each}} From 1875ff869cab5cd1d0f371af815e4e63a1dd5192 Mon Sep 17 00:00:00 2001 From: Charlie Blundell Date: Fri, 4 Mar 2022 00:29:25 +1100 Subject: [PATCH 4/5] Rename conventionalcommits.hbs to conventional.hbs --- templates/{conventionalcommits.hbs => conventional.hbs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename templates/{conventionalcommits.hbs => conventional.hbs} (100%) diff --git a/templates/conventionalcommits.hbs b/templates/conventional.hbs similarity index 100% rename from templates/conventionalcommits.hbs rename to templates/conventional.hbs From 5a0ec4f437ca1200e4cb29145808ac7f3b855f61 Mon Sep 17 00:00:00 2001 From: Charlie Blundell Date: Wed, 23 Mar 2022 16:52:49 +1100 Subject: [PATCH 5/5] Fixed comments and spelling mistakes --- templates/conventional.hbs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/templates/conventional.hbs b/templates/conventional.hbs index 5f9df34b..01438115 100644 --- a/templates/conventional.hbs +++ b/templates/conventional.hbs @@ -23,7 +23,7 @@ Example Definitions --}} -{{!-- In package.json need to add this to remove label text from the change log output (becuase the markdown headers are now used to group them). +{{!-- In package.json need to add this to remove label text from the change log output (because the markdown headers are now used to group them). NOTES • Individual brackets have been escaped twice to be Json compliant. • For items that define a scope eg feat(bldAssess): We remove the 1st bracket and then re-add it so we can select the right piece of text { @@ -63,7 +63,7 @@ Example Definitions \s = whitespace . = any character except newline | = or - [aA] = charcter a or character A + [aA] = character a or character A --}} @@ -91,44 +91,44 @@ Example Definitions {{! List commits with 'breaking:' or 'Breaking change:' anywhere in the message under a heading}} {{#commit-list commits heading='#### Breaking Changes :warning:' message='[bB]reaking [cC]hange:|[bB]reaking:' }} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{! List commits organised under a heading, but not those already listed in the breaking section }} {{#commit-list commits heading='#### New Features' message='^[fF]eat:|[fF]eat\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### Fixes' message='^[fF]ix:|^[fF]ix\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### Chores And Housekeeping' message='^[cC]hore:|^[cC]hore\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### Documentation Changes' message='^[dD]ocs:|^[dD]ocs\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### Refactoring and Updates' message='^[rR]efactor:|^[rR]efactor\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### Changes to Test Assests' message='^[tT]est:|^[tT]est\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### Tidying of Code eg Whitespace' message='^[sS]tyle:|^[sS]tyle\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### Performance Improvments' message='^[pP]erf:|^[pP]erf\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:'}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{#commit-list commits heading='#### General Changes' exclude='[bB]reaking [cC]hange:|[bB]reaking:|^[fF]eat:|^[fF]eat\(|^[fF]ix:|^[fF]ix\(|^[cC]hore:|^[cC]hore\(|^[dD]ocs:|^[dD]ocs\(|^[rR]efactor:|^[rR]efactor\(|^[tT]est:|^[tT]est\(|^[sS]tyle:|^[sS]tyle\(|^[pP]erf:|^[pP]erf\('}} - - {{subject}} @{{author}} + - {{subject}} @{{author}} {{!--[`{{shorthash}}`]({{href}}) --}} {{/commit-list}} {{/each}}