Conventional Commits

Conventional Commits is a convention of writing commit messages so the version of the project can be automatically calculated instead of being manually updated. This is called semantic versioning which means the version number has nothing to do when “when” you think it should be bumped but it is updated as you make changes. This makes it very useful to prevent “final-2” type of versions.

The convention really only applies to the first line. If you use NixOS or another tool, it will be checked while committing to ensure all the rules are in place.

The version is calculated by the prefix of the message which is typically lower case. For example, in Allegro, the log messages show examples.

$ git log --oneline
9ca4e62 chore: bumping version
2660c94 fix: edited 54-61
c919ef7 fix: edit 34-55
7052e17 fix: editing 34-45
14f0e88 feat: working on the 38-46 block
fc21bb7 refactor: inserting a new forty
9f21df5 fix: working on thirty-eight and thirty-nine
1b8305d chore: removing some binaries
249b928 fix: working on thirty-eight
2300c2c chore: bumping version

Here are the rough rules:

  • If the message starts with feat!, then the major version is bumped
  • If the message starts with feat:, the minor version is bumped by one
  • If the message starts with fix:, the patch is bumped by one
  • For everything else (chore, build, refactor), the version number isn't changed