Skip to content

Instantly share code, notes, and snippets.

@Max95Cohen
Created January 27, 2023 18:00
Show Gist options
  • Save Max95Cohen/6b5ddda2721ace4c66ccc11343fb2e4b to your computer and use it in GitHub Desktop.
Save Max95Cohen/6b5ddda2721ace4c66ccc11343fb2e4b to your computer and use it in GitHub Desktop.
pre-commit git hook
#!/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