summaryrefslogtreecommitdiff
path: root/.githooks/commit-msg
blob: 33d6a5feb3f7fc36183e06161a8d66ff0f396289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env bash
# Commit message hook - enforce conventional commit format (optional)

commit_regex='^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\(.+\))?!?: .{1,50}|^fixup!'

if ! grep -qE "$commit_regex" "$1"; then
    echo "❌ Invalid commit message format!"
    echo ""
    echo "Format: type(scope): description"
    echo "Types: feat, fix, docs, style, refactor, test, chore, build, ci, perf"
    echo "Example: feat(auth): add user login functionality"
    echo ""
    echo "Your message: $(cat $1)"
    exit 1
fi