-
-
Save SyllaJay/f52bab41503c03236b4bcc14dc557f6c to your computer and use it in GitHub Desktop.
git pre-commit hook to check branch name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Pre-commit hooks | |
# Check branch name | |
BRANCH_NAME_LENGTH=`git rev-parse --abbrev-ref HEAD | grep -E '^t[0-9]{2,16}\_.*_[A-Za-z]{2,2}$' | wc -c` | |
if [ ${BRANCH_NAME_LENGTH} -eq 0 ] ; then | |
echo -e '\E[37;44m'"\033[1mERROR\033[0m in pre-commit hook: vim /export/web/.git/hooks/pre-commit" | |
echo "Branch name should be like t00000_blah_blah_CA - brand is two letters" | |
echo "edit regexp if you think something wrong" | |
echo "Skip pre-commit hooks with --no-verify (not recommended)." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment