Skip to content

Instantly share code, notes, and snippets.

@mpawelski
mpawelski / commit-msg
Last active August 29, 2018 20:27
Git hook to append Jira issue number to commit message basing on branch name
#! /bin/bash
# This hook checks if git commit message (first line) contains Jira
# ticket (for example TEST-123) and if not prepends it to commit message
# based on current branch name (for example from bugfix/TEST-123-quickfix
# branch name we'll prepend "TEST-123:" to git commit message)
# This script is called by "git commit" with one argument, the name of
# the file that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the