Skip to content

Commit 85d58b6

Browse files
feat: updated husky rules
1 parent 37db124 commit 85d58b6

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

.husky/pre-commit

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
1+
#!/usr/bin/env sh
2+
branch_name="$(git branch --show-current)"
3+
branch_regex="^(bug|chore|feat)\/([a-zA-Z]+-[0-9]+)(-(.*))?"
34

4-
npx lint-staged
5+
if [[ ! $branch_name =~ $branch_regex ]]; then
6+
echo "Branch name does not match expected format. Ex. feat/TYPE-000"
7+
exit 1
8+
fi
59

6-
exit 0
10+
11+
npx lint-staged

.husky/prepare-commit-msg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
commit_message_file=$1
3+
COMMIT_SOURCE=$2
4+
echo $commit_message
5+
commit_message=$(cat $commit_message_file)
6+
commit_regex="^(bug|chore|feat):.*"
7+
8+
if [[ $commit_message == Merge* ]]; then
9+
echo "Commit source is merge. Skipping commit message validation..."
10+
exit 0
11+
fi
12+
13+
if [[ ! $commit_message =~ $commit_regex ]]; then
14+
echo "Commit message does not match expected format. Ex. feat: short description"
15+
exit 1
16+
fi

0 commit comments

Comments
 (0)