DlekaShelHaHaim
DlekaShelHaHaim

Reputation: 227

How to enforce conventional commit messages in git (Bitbucket)

I'm looking for a way to prevent commits which have no correct format for the commit message.
I intend to use the following convention:
https://www.conventionalcommits.org/en/v1.0.0/

I found out there is a folder with bash scripts which may be the key to that solution: .git/hooks/

However, I'm not sure how to write the script to enforce the format on the commit messages.

Will edit accordingly, thank you in advance.

Upvotes: 5

Views: 11697

Answers (2)

Shtev
Shtev

Reputation: 41

The official Conventional Commits website maintains a list of tools to aid in enforcement, management and configuration.

I've linked to it directly, as it isn't immediately obvious on the site where that is. For anyone curious, it is under the "about" section.

The list is not exhaustive, but a very good place to start. The tools are varied, ranging from "complete" solutions that handle rule enforcement and standards, to "helpers" that simplify a single part of the process. Explore and find the tools that work best for you.

Upvotes: 1

Timon van der Berg
Timon van der Berg

Reputation: 586

There is a list of Tools in the documentation.

My suggestion would be to:

  1. Pick a tool.
  2. Run it from the command line, and see if you can get it to check commit messages.
  3. Put the commands you use to check commits messages in a git hook.

Upvotes: 5

Related Questions