Skip to content

Commit

Permalink
chore: change changelog commit template to modified conventionalcommits
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinfreund committed Nov 23, 2023
1 parent f823f0e commit c52f765
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
44 changes: 43 additions & 1 deletion changelog-template-commit.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
{{!--
Copy of https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-conventionalcommits/templates/commit.hbs
The following have been replaced:
- `commitUrlFormat` with `{{@root.host}}/{{@root.owner}}/{{@root.repository}}/commit/{{hash}})`
- `issueUrlFormat` with `{{@root.host}}/{{@root.owner}}/{{@root.repository}}/issues/{{this.id}}`
As they won't be replaced when overriding the commitPartial
--}}
*{{#if scope}} **{{scope}}:**
{{~/if}} {{#if subject}}
{{~subject}}
{{~else}}
{{~header}}
{{~/if}}

{{~!-- commit link --}}{{~#if hash}} {{#if @root.linkReferences~}}
([{{shortHash}}]({{@root.host}}/{{@root.owner}}/{{@root.repository}}/commit/{{hash}}))
{{~else}}
{{~shortHash}}
{{~/if}}{{~/if}}

{{~!-- commit references --}}
{{~#if references~}}
, closes
{{~#each references}} {{#if @root.linkReferences~}}
[
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}{{this.prefix}}{{this.issue}}]({{@root.host}}/{{@root.owner}}/{{@root.repository}}/issues/{{this.id}})
{{~else}}
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}{{this.prefix}}{{this.issue}}
{{~/if}}{{/each}}
{{~/if}}
{{!-- End of copy --}}

{{!-- Start of custom additions --}}
{{#each bodyLines}}

{{this}}
{{/each}}{{#each notes}}

**BREAKING CHANGE**: {{text}}
{{/each}}
{{/each}}
6 changes: 1 addition & 5 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { readFileSync } from 'node:fs'

// Since all I need is to append something to the default commit template, I read the original file and append to it instead of copying its contents. This way, the default template will always be up-to-date.
// Note: I'm intentionally using a different template here than the conventionalcommits one because there seems to be an issue with adding the commit hash URLs.
const defaultCommitPartial = readFileSync('./node_modules/conventional-changelog-writer/templates/commit.hbs', { encoding: 'utf-8' })
const customCommitPartial = readFileSync('./changelog-template-commit.hbs', { encoding: 'utf-8' })
const commitPartial = defaultCommitPartial + customCommitPartial
const commitPartial = readFileSync('./changelog-template-commit.hbs', { encoding: 'utf-8' })

/**
* Adds the commit body line by line so I can add it with the correct indentation in `changelog-template-commit.hbs`.
Expand Down

0 comments on commit c52f765

Please sign in to comment.