unreal-automations/install_hook.sh

27 lines
710 B
Bash
Raw Normal View History

2025-03-05 07:52:49 +00:00
#!/bin/bash
2025-03-05 14:23:04 +00:00
HOOK_TYPE="pre-push" # Changement ici
GIT_HOOKS_DIR="$(git rev-parse --git-path hooks)"
TARGET_HOOK="$GIT_HOOKS_DIR/$HOOK_TYPE"
2025-03-05 07:52:49 +00:00
2025-03-05 14:23:04 +00:00
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
2025-03-05 15:11:41 +00:00
"\\\$ROOT_DIR/.tools/format_code.sh" --verbose --modified-only || exit 1
2025-03-05 07:52:49 +00:00
2025-03-05 14:23:04 +00:00
# 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
2025-03-05 07:52:49 +00:00
2025-03-05 14:23:04 +00:00
chmod +x "$TARGET_HOOK"
echo "Hook $HOOK_TYPE installé avec succès !"