This file contains hidden or 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 | |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) | |
PREFIX_PATTERN='[A-Za-z]{2,10}(-|_)[0-9]{1,6}' | |
# Ensure BRANCH_NAME is not empty and is not in a detached HEAD state (i.e. rebase). | |
# SKIP_PREPARE_COMMIT_MSG may be used as an escape hatch to disable this hook, | |
# while still allowing other githooks to run. | |
if [ ! -z "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "HEAD" ] && [ "$SKIP_PREPARE_COMMIT_MSG" != 1 ] && [[ $BRANCH_NAME =~ $PREFIX_PATTERN ]]; then |