30 lines
676 B
Bash
30 lines
676 B
Bash
#!/bin/sh
|
|
|
|
# Hook: commit-msg
|
|
# Validates the commit message format.
|
|
# Git passes the path to the temp message file as $1.
|
|
|
|
COMMIT_MSG=$(cat "$1")
|
|
|
|
# Skip validation for rebase or CI commits
|
|
if echo "$COMMIT_MSG" | grep -qiE "(Rebase|rebase|CI|merge|Merge)"; then
|
|
exit 0
|
|
fi
|
|
|
|
if [ ${#COMMIT_MSG} -le 10 ]; then
|
|
echo "❌ Erreur : Le message doit faire plus de 10 caractères."
|
|
exit 1
|
|
fi
|
|
|
|
if ! echo "$COMMIT_MSG" | grep -q "\.$"; then
|
|
echo "❌ Erreur : Le commit doit se terminer par un point."
|
|
exit 1
|
|
fi
|
|
|
|
if ! echo "$COMMIT_MSG" | grep -q "#[0-9]\+"; then
|
|
echo "❌ Erreur : Vous devez faire référence à un ticket (ex: #123)."
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|