Created
August 29, 2019 19:30
-
-
Save reed-jones/433d368a6b75f67eac98c69df87e6964 to your computer and use it in GitHub Desktop.
Git branch name check
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
#!/usr/bin/env bash | |
LC_ALL=C | |
local_branch="$(git rev-parse --abbrev-ref HEAD)" | |
valid_branch_regex="^(feature|bugfix|wip|junk|release|hotfix)\/[a-z0-9._-]+$" | |
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your push will be rejected. You should rename your branch to a valid name and try again." | |
if [[ ! $local_branch =~ $valid_branch_regex ]] | |
then | |
echo "$message" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment