-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Project): enforce branch name policy
- Loading branch information
1 parent
91f2c61
commit d7a04eb
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Colors | ||
RED='\033[0;31m' | ||
YELLOW='\033[0;33m' | ||
CLEARCOLOR='\033[0m' | ||
|
||
local_branch_name="$(git rev-parse --abbrev-ref HEAD)" | ||
allowed_branch_names="feat|fix|test|docs|style|chore|perf|refactor|revert|ci|build" | ||
|
||
message="❌ ${RED}There is something wrong with your branch name${CLEARCOLOR} ❌\\n\ | ||
Branch names in this project must adhere to this contract:\\n\ | ||
<prefix>/<name>\\n\ | ||
where prefix is one of: | ||
$allowed_branch_names\\n\ | ||
${YELLOW}Please, rename your branch to a valid name and try again.${CLEARCOLOR}\\n" | ||
|
||
branch_name_check="^(($allowed_branch_names)\/[a-zA-Z0-9\-]+)$" | ||
if [[ ! $local_branch_name =~ $branch_name_check ]]; then | ||
echo "$message" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
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