Files
Olhar-API/.githooks/pre-commit
T
2026-06-07 11:02:16 +02:00

29 lines
863 B
Bash
Executable File

#!/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