-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged | ||
npx lint-staged && npm run check-branch-name |
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,23 @@ | ||
#!/usr/bin/env bash | ||
local_branch_name="$(git rev-parse --abbrev-ref HEAD)" | ||
|
||
# This regular expression is: | ||
# 1. checking for branch Names: "dev" or "main" | ||
# - ^(dev|main)$) | ||
# 2. checking for branch Name starting with fix,ft,ht,chore or doc follwed by a "/" then the "branch name" | ||
# - ^((fix|ft|ht|chore|doc)\/[a-zA-Z0-9\-]+)$ | ||
valid_branch_regex='^(dev|main)$|^((fix|ft|ht|chore|doc)\/[a-zA-Z0-9\-]+)$' | ||
|
||
green='\033[0;32m' | ||
red='\033[0;31m' | ||
clear='\033[0m' | ||
|
||
message="❌❌❌❌ There is something wrong with your branch name $local_branch_name.\nBranch names in this project must adhere to the format specified in the CONTRIBUTING guide.\nYour commit will be rejected. You should rename your branch to a valid name and try again" | ||
|
||
if [[ ! $local_branch_name =~ $valid_branch_regex ]]; then | ||
echo -e "${red}$message${clear}" | ||
exit 1 | ||
fi | ||
|
||
echo -e "${green}Branch name check passed ✅${clear}" | ||
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