unreal-automations/install_hook.sh
2025-03-05 15:50:51 +01:00

27 lines
No EOL
720 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" --dry-run --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 !"