Skip to content

Instantly share code, notes, and snippets.

@anatooly
Created August 12, 2022 09:40
Show Gist options
  • Save anatooly/e4ab60ceac8912a3f137cfef82807525 to your computer and use it in GitHub Desktop.
Save anatooly/e4ab60ceac8912a3f137cfef82807525 to your computer and use it in GitHub Desktop.
pre-commit
#!/bin/bash
#
# Pre-commit hooks
# Check branch name
BRANCH_NAME_LENGTH=`git rev-parse --abbrev-ref HEAD | grep -E '^(?!((fix|feature)\/[a-zA-Z0-9\-]+)$).*' | wc -c`
if [ ${BRANCH_NAME_LENGTH} -eq 0 ] ; then
echo -e '\E[37;44m'"\033[1mERROR\033[0m in pre-commit hook: vim .git/hooks/pre-commit"
echo "Branch name should be like feature/lowerUpper09-EXY-134 - 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