Created
January 27, 2023 18:01
-
-
Save Max95Cohen/520f25bc8471c6ca4e78d7245350e044 to your computer and use it in GitHub Desktop.
commit-msg git hook
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 | |
REGEX_ISSUE_ID="^((ISSUE|TASK)\-[0-9]+)" | |
ISSUE_ID_IN_COMMIT=$(echo $(cat "$1") | grep -o -E "$REGEX_ISSUE_ID") | |
if [[ -z "$ISSUE_ID_IN_COMMIT" ]]; then | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
printf "\nYour commit message is illegal. Please add branch name \"${RED}$BRANCH_NAME: ${NC}\" to start of messagei as prefix.\n\n" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment