Skip to content

Commit a6a9eff

Browse files
committed
feat: add commit message validation script for Conventional Commits
1 parent 5e4f6d9 commit a6a9eff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.githooks/commit-msg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
# Conventional Commits validation
3+
4+
commit_regex='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .{1,50}'
5+
6+
if ! grep -qE "$commit_regex" "$1"; then
7+
echo "Invalid commit message format!"
8+
echo "Please use: <type>[optional scope]: <description>"
9+
echo "Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
10+
echo "Example without scope: feat: add new feature"
11+
echo "Example with scope: feat(parser): add new parsing feature"
12+
exit 1
13+
fi

0 commit comments

Comments
 (0)