Commit-msg Hook

Every developer must have this hook on his local machine in order to:

  • Commit codes locally several times then pushes it to the server.
  • Merge auto-commits with auto-messages without referencing to a Jira ticket.

The commit-msg hook is a python script file and it must be placed in the developer's local repository as: .git/hooks/commit-msg.  There is no server-side hook required.

The following settings must be configured in the script file:

  • JIRA_HOST_NAME -- hostname of the Jira.
Example: jira.example.com
  • JIRA_USER, JIRA_PASSWORD -- developer's credentials.
  • JIRA_TICKET_PATTERN -- pattern that will search ticket references.
Example: re.compile(r'\[(\w+7-\d+?)\]')

In Linux and OSX, this file must have executable permissions in the file system; in Windows, setting this permission is not necessary.  To use the hook in Windows without python installed, see Python on Windows FAQ ».

See the commit-msg hook code on the right panel or download the sample commit-msg file ↓, make the necessary changes, and place it in the required folder.