Git commit msg - is there any way to handle it from server side hooks?


I have a script (commit-msg hook ) which checks for the jira ticket in commit message, i know it has to be handled at client side hooks, but just want to confirm is there any way to handle it from server side hooks?

if client side then i need the commit-msg hook to be applied for all the existing branches and for feature branches so is there any one time configuration to set up it, rather developers set it every time when they create branches.

if server side then please provide some links on how to configure it through bitbucket.

I do not really see how this question is related to elixir, but you could simply add the hook to git: git add .git/hooks/commit-msg.

But in my opinion you really shouldn’t do that.

  • You need to ensure that all programs used in the hook are available on the developers PC.
  • Its hard to create cross OS hooks
  • Repeating the very same ticket number in all commits of the bug-fix or feature branch will spam the ticket view with “has been referenced in commit deadbeef”

To my experience it is enough to have the main addressed ticket in the branch name (eg. CHESS-1-implement-pawn) and only reference other tickets if needed in the commit message and only from prose or subject line. Do not introduce a “REF”-section.

Only in the final commit to a branch or in the merge do a FIX CHESS-1 in the commit message.

Last but not least, you really shouldn’t rely on client side hooks anywhere, as every comitter has --skip-verify at his hands.

Thank you for the reply, anyways git add for hooks doesn’t work as they are not under version control.

Oh, yeah, git refuses to add them.

You still could provide some kind of setup script which creates the hooks.

But don’t force your devs. They will just remove them as soon as the hooks get in their way.