Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch to include commit body #242

Open
derekgreer opened this issue May 11, 2018 · 28 comments
Open

Add switch to include commit body #242

derekgreer opened this issue May 11, 2018 · 28 comments

Comments

@derekgreer
Copy link

Currently standard-version only includes the commit header. Is there a way to optionally include the commit body in the CHANGELOG.md? Is there a sister tool I should be using to generate release notes to end users that provide all the details?

@ffxsam
Copy link

ffxsam commented Mar 22, 2019

@derekgreer Interesting no one noticed this, it's a great idea. When we squash our PRs on GitHub, it puts the squashed commits into the body, e.g.:

commit c18e83e1c45644ef7c81adae7fa7ed4581292b25
Author: Person
Date:   Wed Mar 20 16:46:13 2019 -0500

    feat(Downloads): Download modal improvements (#87)

    * fix: Some fix

    * fix: Updated things

    * fix: Did another thing

It would be cool if that body could be put into the changelog as an indented list underneath the main commit message.

@ffxsam
Copy link

ffxsam commented Mar 22, 2019

@bcoe @stevemao Thoughts on this?

@willvincent
Copy link

willvincent commented Mar 22, 2019

Even just having extra detail beyond the first line, other than only breaking changes would be useful. Whether that's a list of commits in a PR being merged in, or descriptive text added manually as part of the commit message.

Some new features, or involved fixes may warrant additional description above and beyond the one line. Suggesting "you can manually edit the changelog" as has been mentioned in other issues, to my mind, kind of largely defeats the purpose of using an automated tool... if the info is already in the commit, it should be able to be pulled out of the commit log and injected into the change log. Especially if changelogs aren't being generated immediately every time there's a PR merge, or whatever.. having to then go back and manually add some description to the generated file, sometime in the future, is not very reasonable.

@bcoe
Copy link
Member

bcoe commented Mar 22, 2019

see motivation for a more flexible preset: conventional-changelog/conventional-changelog#421

@stevemao
Copy link
Member

stevemao commented Mar 23, 2019

Maybe, we can use <details> tag for commit body?

@bcoe
Copy link
Member

bcoe commented Mar 25, 2019

@stevemao this seems clever 😄 (in the good sense of the word). I might still be inclined to make it a config option that gets turned on.

@joshtoper
Copy link

Was any progress made on this? This tool is fab but I require the full commit message in the Changelog, rather than just the header.

@stevemao Can you elaborate on what you meant re the <details> tag please?

@stevemao
Copy link
Member

stevemao commented Nov 4, 2019

@joshtoper see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details
I was just throwing random idea.

@polaroidkidd
Copy link

I'm really in favour of this idea. I've done away with the develop branch in my projects as I tend to work myself from feature/issue to feature/issue and publish asap. Having the commit body included in the changelog would be very helpful in providing some context to the changelog.

@Feiyang1
Copy link

Feiyang1 commented May 5, 2020

Any progress or plan on supporting this? I'm also very interested in being able to customize changelog generation, as I may want to only include a section of the commit body in the changelog.

@crutchcorn
Copy link

This would be extremely helpful for many of my projects. I'd love to be able to outline a majority of the changes in my CHANGELOG by using a commit body without ejecting:

oceanbit/react-native-button-toggle-group@9b79bc6

@willvincent
Copy link

@crutchcorn Perfect use case scenario.

@crutchcorn
Copy link

I'm going to be looking into adding this functionality. Linking related issues:

conventional-changelog/conventional-changelog#338

conventional-changelog/conventional-changelog#423

@bcoe
Copy link
Member

bcoe commented Jul 9, 2020

@crutchcorn I've been slammed with various other projects recently, but would appreciate the patch 👍

this chat can potentially be a good place to coordinate.

@patrickmichalina
Copy link

@crutchcorn do you intend to make a simple option to enable this feature instead of needing to create a customized template?

@crutchcorn
Copy link

@patrickmichalina I plan on making it a simple toggle.

I've been reading through the source code of the dependencies and have an idea of how to add to this, but it's kinda down my priority list. I'll try taking a stab throughout the week or two, but it might take me a bit to get through

@Oloremo
Copy link

Oloremo commented Aug 24, 2020

Looking forward to this feature as well

@derekgreer
Copy link
Author

Any updates?

@mheunem
Copy link

mheunem commented Nov 2, 2020

I've some changes: #675
In my implementation, you can define own templates to show a body per commit message.

@A11oW
Copy link

A11oW commented Oct 4, 2021

Any news?

@kyranjamie
Copy link

Would love to see this feature get merged. The body text describes rich information that's absolutely worthy of going in the release notes.

@ddx32
Copy link

ddx32 commented Jun 1, 2022

Just a heads up if anyone needs to implement this now to their project, it's possible with a little configuration and a custom commit template. It's a bit tricky with whitespace handling in Handlebars + Markdown formatting, mine is definitely a little rough around the edges and YMMV based on how you format commit messages, but it works for us :) Suggestions welcome.

First, you need your semantic-release config in a release.config.js file, so you can use Node to inject the template into the config:

const { readFileSync } = require('fs')
const { join } = require('path')

module.exports = {
  plugins: [
    ...
    [
      '@semantic-release/release-notes-generator',
      {
        writerOpts: {
          commitPartial: readFileSync(join(__dirname, 'path/to/commit.hbs'), 'utf-8')
        }
      }
    ],
    ...
  ]
}

And here's my modified commit.hbs:

{{#if scope}} **{{scope}}:**
{{~/if}} {{#if subject}}
  {{~subject}}
{{~else}}
  {{~header}}
{{~/if}}

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

{{~!-- commit references --}}
{{~#if references~}}
  , closes
  {{~#each references}} {{#if @root.linkReferences~}}
    [
    {{~#if this.owner}}
      {{~this.owner}}/
    {{~/if}}
    {{~this.repository}}#{{this.issue}}](
    {{~#if @root.repository}}
      {{~#if @root.host}}
        {{~@root.host}}/
      {{~/if}}
      {{~#if this.repository}}
        {{~#if this.owner}}
          {{~this.owner}}/
        {{~/if}}
        {{~this.repository}}
      {{~else}}
        {{~#if @root.owner}}
          {{~@root.owner}}/
        {{~/if}}
          {{~@root.repository}}
        {{~/if}}
    {{~else}}
      {{~@root.repoUrl}}
    {{~/if}}/
    {{~@root.issue}}/{{this.issue}})
  {{~else}}
    {{~#if this.owner}}
      {{~this.owner}}/
    {{~/if}}
    {{~this.repository}}#{{this.issue}}
  {{~/if}}{{/each}}
{{~/if}}
 
{{~#if body}}
{{{{raw}}}}
  
{{{{/raw}}}}
{{body}}
{{~/if}}

{{{{raw}}}}
  
{{{{/raw}}}}

@kevinbreaker
Copy link

Thank you very much, @ddx32 !! Your solution works fine for me!

@padamstx
Copy link

My team uses semantic-release for a large number of projects and this feature would be awesome to provide more detail in Changelogs.
Any plans to deliver this feature?

@aasen
Copy link

aasen commented Feb 28, 2023

I'm using lerna, which relies on conventional-changelog for automated changelogs.

Being able to include commit body in changelog would be an amazing improvement.

Is there any plans to add this feature, super-easy research (among devs in my company) reveals that this is a VERY popular improvement 💪🏻

Thanks for all your good work!

@ipleten
Copy link

ipleten commented Mar 29, 2023

Also looking to how to add body to lerna's changelog.

@adrianschmidt
Copy link

adrianschmidt commented Aug 10, 2023

I would like to add that having a way to specify a section of the commit message body that goes into the changelog would be extra valuable to me.

This way, you can add both a message directed at other developers of the same project (which doesn't show up in the changelog), and a message directed at the readers of the changelog (be they end users or developers of some code consuming your project).

In the meanwhile, big thanks to @ddx32! Your suggestion seems to solve most of what I need 🙏 ❤️

EDIT: here's the commit where I implemented ddx32's suggestion in our project, in case anyone finds it helpful to see it used in a real world situation.

@arijitcodes
Copy link

arijitcodes commented Oct 11, 2023

Just a heads up if anyone needs to implement this now to their project, it's possible with a little configuration and a custom commit template. It's a bit tricky with whitespace handling in Handlebars + Markdown formatting, mine is definitely a little rough around the edges and YMMV based on how you format commit messages, but it works for us :) Suggestions welcome.

First, you need your semantic-release config in a release.config.js file, so you can use Node to inject the template into the config:

const { readFileSync } = require('fs')
const { join } = require('path')

module.exports = {
  plugins: [
    ...
    [
      '@semantic-release/release-notes-generator',
      {
        writerOpts: {
          commitPartial: readFileSync(join(__dirname, 'path/to/commit.hbs'), 'utf-8')
        }
      }
    ],
    ...
  ]
}

And here's my modified commit.hbs:

✅{{#if scope}} **{{scope}}:**
{{~/if}} {{#if subject}}
  {{~subject}}
{{~else}}
  {{~header}}
{{~/if}}

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

{{~!-- commit references --}}
{{~#if references~}}
  , closes
  {{~#each references}} {{#if @root.linkReferences~}}
    [
    {{~#if this.owner}}
      {{~this.owner}}/
    {{~/if}}
    {{~this.repository}}#{{this.issue}}](
    {{~#if @root.repository}}
      {{~#if @root.host}}
        {{~@root.host}}/
      {{~/if}}
      {{~#if this.repository}}
        {{~#if this.owner}}
          {{~this.owner}}/
        {{~/if}}
        {{~this.repository}}
      {{~else}}
        {{~#if @root.owner}}
          {{~@root.owner}}/
        {{~/if}}
          {{~@root.repository}}
        {{~/if}}
    {{~else}}
      {{~@root.repoUrl}}
    {{~/if}}/
    {{~@root.issue}}/{{this.issue}})
  {{~else}}
    {{~#if this.owner}}
      {{~this.owner}}/
    {{~/if}}
    {{~this.repository}}#{{this.issue}}
  {{~/if}}{{/each}}
{{~/if}}
 
{{~#if body}}
{{{{raw}}}}
  
{{{{/raw}}}}
{{body}}
{{~/if}}

{{{{raw}}}}
  
{{{{/raw}}}}

Works pretty well! Thank you soo much @ddx32 for sharing your solution! Saved me days of googling and trial and error... 🙏🏻🙌🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests