conventional-changelog / standard-version

:trophy: Automate versioning and CHANGELOG generation, with semver.org and conventionalcommits.org
ISC License
7.69k stars 794 forks source link

commit hook, run standard-version only when the changelog needs changed #923

Closed letto4135 closed 2 years ago

letto4135 commented 2 years ago

Making up a public changelog so there are certain things that I don't want shown like refactors and such, only show things that effect the user essentially.

Is there a way to use a post-commit hook to run standard-version only if there is a change that needs to be made to the changelog? Only other options I can see are manually running it, or bumping the version even when nothing will show in the changelog.

letto4135 commented 2 years ago

Answered my own question after a while of messing around.

"husky": {
    "hooks": {
      "post-commit": "commitmessage=`git log -1 --pretty=%B | grep -q -e fix -e feat; echo $?`; if [ $commitmessage == 0 ]; then npm run release patch; fi"
     }
}