Created
December 16, 2022 13:13
-
-
Save Laurentyb/d762c964c766bcf469209bdf8ac30c46 to your computer and use it in GitHub Desktop.
Git hook for validating branch names before commiting
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/sh | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
REGEX="^(develop|master|production|staging|uat|main|release|((feature|devops|bugfix|hotfix)\/[A-Z]+-[0-9]+_[A-Z]+_.+))$" | |
if ! [[ $BRANCH =~ $REGEX ]]; then | |
echo "Your commit was rejected due to branching name" | |
echo "Please rename your branch with $REGEX syntax" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment