27 lines
No EOL
710 B
Bash
27 lines
No EOL
710 B
Bash
#!/bin/bash
|
|
|
|
HOOK_TYPE="pre-push" # Changement ici
|
|
GIT_HOOKS_DIR="$(git rev-parse --git-path hooks)"
|
|
TARGET_HOOK="$GIT_HOOKS_DIR/$HOOK_TYPE"
|
|
|
|
cat > "$TARGET_HOOK" <<EOL
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
ROOT_DIR=\$(git rev-parse --show-toplevel)
|
|
export PATH="\\\$PATH:\\\$ROOT_DIR/.tools"
|
|
|
|
# Lancer le check de formatage
|
|
"\\\$ROOT_DIR/.tools/format_code.sh" --verbose --modified-only || exit 1
|
|
|
|
# Vérifier les modifications non poussées
|
|
git diff --cached --quiet || {
|
|
echo -e "\\n❌ Des modifications formatées ne sont pas dans le commit final !"
|
|
echo "Utilisez 'git add . && git commit --amend' pour corriger"
|
|
exit 1
|
|
}
|
|
EOL
|
|
|
|
chmod +x "$TARGET_HOOK"
|
|
echo "Hook $HOOK_TYPE installé avec succès !" |