diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..212c8a6 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO_ROOT=$(git rev-parse --show-toplevel) +BRANCH=$(git symbolic-ref --short HEAD) + +echo "🔄 Pre-commit : synchronisation avec origin/$BRANCH..." +if ! git pull --rebase --autostash origin "$BRANCH"; then + echo "❌ git pull --rebase a échoué — résous les conflits avant de committer" + exit 1 +fi + +echo "🧪 Pre-commit : exécution des tests..." +if podman run --rm \ + --privileged \ + --network host \ + -v "$REPO_ROOT":/workspace:Z \ + -v /run/user/"$(id -u)"/podman/podman.sock:/var/run/docker.sock:Z \ + -e DOCKER_HOST=unix:///var/run/docker.sock \ + -e TESTCONTAINERS_RYUK_DISABLED=true \ + -w /workspace \ + eclipse-temurin:25-jdk \ + ./gradlew test --no-daemon; then + echo "✅ Tests réussis — commit autorisé" +else + echo "❌ Tests échoués — commit annulé" + exit 1 +fi