Skip to content

Instantly share code, notes, and snippets.

@thomasgassmann
Forked from pgilad/Instructions.md
Last active October 23, 2018 10:21
Show Gist options
  • Select an option

  • Save thomasgassmann/85c4d40993339ced3c73016f3fd9b3af to your computer and use it in GitHub Desktop.

Select an option

Save thomasgassmann/85c4d40993339ced3c73016f3fd9b3af to your computer and use it in GitHub Desktop.
Git commit-msg hook to validate for jira issue or the word merge
#!/usr/bin/env bash
error_msg="Aborting commit. Your commit message does not match the regex. Please provide a format like: '#666 foo bar'"
msg="`cat $1`"
if [[ ! $msg =~ ^#[0-9]{3,9}(.|\n)* ]]; then
echo "$error_msg" >&2
exit 1
fi

Installation

Linux

curl https://gist.github.com/ThomasGassmann/85c4d40993339ced3c73016f3fd9b3af/raw/commit-msg.sh > .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg

Windows

curl https://gist.github.com/ThomasGassmann/85c4d40993339ced3c73016f3fd9b3af/raw/commit-msg.sh > .git/hooks/commit-msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment