Skip to content

Instantly share code, notes, and snippets.

@perifer
Created December 29, 2022 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perifer/cc493672764caee3f02a6cc49dbb00fc to your computer and use it in GitHub Desktop.
Save perifer/cc493672764caee3f02a6cc49dbb00fc to your computer and use it in GitHub Desktop.
Branching policy
#!/usr/bin/env bash
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(feature|bugfix|release|hotfix|archive)\/[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. 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
@perifer
Copy link
Author

perifer commented Dec 29, 2022

Add to .git/hooks . Don't forget to make it executable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment