DEV Community

Discussion on: How much effort do you put into commit messages?

Collapse
 
pbnj profile image
Peter Benjamin (they/them) • Edited

I follow the Conventional Commit standard, because it allows me to automate Semantic Versioning in CI pipelines.

Examples:

  • Added a new CLI command? $ git commit -m "feat: add foo command" && git push then CI tests, builds, and increments MINOR version 1.0.9 -> 1.1.0, and publishes artifacts.

  • Fixed a race condition bug? $ git commit -m "fix: fix race condition" && git push then CI tests, builds, and increments PATCH version 1.1.0 -> 1.1.1, and publishes artifacts.

  • If a feature or bug fix is non-backward compatible, then add BREAKING CHANGE in git commit message, which will lead to incrementing the MAJOR version 1.1.1 -> 2.0.

If any change needs some context (eg why the change was made), I add it in the commit message body. More often, I reference the ticket or issue in bug tracker, like:

$ git commit -F- <<EOF
fix: fix race condition

Closes #123
EOF
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tsadarsh profile image
Adarsh TS

This looks interesting. I should look this up soon. Maybe I can reach out to you, if I need some help.

Collapse
 
jack profile image
Jack Williams

I like this, I'm curious, do you use something automated to handle your semantic versioning like this?

Collapse
 
pbnj profile image
Peter Benjamin (they/them)

I use semantic-release for all my projects. I like it because it is language-agnostic.

  1. Add a .releaserc.json config file, which supports a large number of plugins.
  2. Run semantic-release CLI in CI.