add git hooks for commit validation, auto-suggestions, and Docker build/push automation on git push
This commit is contained in:
27
.githooks/commit-msg
Executable file
27
.githooks/commit-msg
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Commit message hook: validate commit message format
|
||||
|
||||
COMMIT_MSG_FILE=$1
|
||||
MSG=$(head -n1 "$COMMIT_MSG_FILE")
|
||||
|
||||
# Skip validation for merge commits
|
||||
if echo "$MSG" | grep -q "^Merge"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check message length
|
||||
if [ ${#MSG} -lt 5 ]; then
|
||||
echo "❌ Commit message too short (min 5 characters)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Optional: enforce conventional commits format
|
||||
# Uncomment if you want to enforce prefixes like "feat:", "fix:", etc.
|
||||
# if ! echo "$MSG" | grep -qE "^(feat|fix|docs|style|refactor|test|chore|backend|frontend|deploy)(\(.+\))?:"; then
|
||||
# echo "❌ Commit message should follow format: type: description"
|
||||
# echo " Allowed types: feat, fix, docs, style, refactor, test, chore, backend, frontend, deploy"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
echo "✅ Commit message OK"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user