Skip to content

Instantly share code, notes, and snippets.

@jmoubry
Forked from pgilad/Instructions.md
Last active December 13, 2018 21:30
Show Gist options
  • Select an option

  • Save jmoubry/e1caa1b4f4a3e01c7d6348c6ac0d972f to your computer and use it in GitHub Desktop.

Select an option

Save jmoubry/e1caa1b4f4a3e01c7d6348c6ac0d972f 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
# regex to validate in commit msg
commit_regex='((OPS|ECOMM|PRODEV|INT)-[0-9]+|merge)'
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('PRODEV-111') or 'Merge'"
if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi

Instructions

  • Click on the Terminal button in SourceTree
  • Run cd T:\BuildASign in the Terminal
  • Paste the script below into the Terminal and hit Enter

Add commit hook to all git repos in the current directory

for f in */.git
do
  echo "Processing $f ..."

  cd T:\BuildASign
  cd $f

  mkdir -p hooks

  curl https://gist.githubusercontent.com/jmoubry/e1caa1b4f4a3e01c7d6348c6ac0d972f/raw/commit-msg.sh > hooks/commit-msg

  chmod +x hooks/commit-msg

done 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment