post-commi hook to check format of message

Hello, I am trying to setup a post-commit hook to check the format of the commit message (basically to enforce that it references a corresponding Jira issue number). I see some threads about POST messages, but I'm unclear how to set this up and how it can deny the commit if that's what we want it to do?

Should I be thinking of this in terms of each user's git repository? Do we embed the post-commit hook into the .git directory and then rely on this working PRIOR to any pushes?

1 answer

1 accepted

Hi,

You need to implement a client-side hook for this. Why? You want to check the commit message before it reaches Bitbucket. The BB POST service executes as a post-receive hook.

Post-commit hooks are client-side hooks that happen after a commit is processed. It is usually used for notifications. You most likely want a commit-msg hook.

Great doc on Git commit hooks:

http://git-scm.com/book/en/Customizing-Git-Git-Hooks

Google "git commit-msg hook" to find helpful examples.

Mary

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

29,779 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you