Created
January 27, 2023 18:00
-
-
Save Max95Cohen/6b5ddda2721ace4c66ccc11343fb2e4b to your computer and use it in GitHub Desktop.
pre-commit 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_BRANCH=$(echo $(git rev-parse --abbrev-ref HEAD) | grep -o -E "$REGEX_ISSUE_ID") | |
if [[ -z "$ISSUE_ID_IN_BRANCH" ]]; then | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
printf "\nYour branch name is illegal. Please rename your branch with using following by ${RED}ISSUE${NC} | ${RED}TASK${NC}.\n\n" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment