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 b5067a4 commit dea4a25
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
50 changes: 44 additions & 6 deletions changelog-template-commit.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
{{#each bodyLines}}
{{!--
Copy of https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-conventionalcommits/templates/commit.hbs
{{this}}
The following have been replaced:
{{/each}}
- `commitUrlFormat` with `{{@root.host}}/{{@root.owner}}/{{@root.repository}}/commit/{{hash}})`
- `issueUrlFormat` with `{{@root.host}}/{{@root.owner}}/{{@root.repository}}/issues/{{this.id}}`
{{#each notes}}
As they won't be replaced when overriding the commitPartial
--}}
*{{#if scope}} **{{scope}}:**
{{~/if}} {{#if subject}}
{{~subject}}
{{~else}}
{{~header}}
{{~/if}}

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

{{/each}}
{{~!-- 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}}
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 dea4a25

Please sign in to comment.