From 9bc3a98d44928350764b5b83cb05d90dfeffe2c3 Mon Sep 17 00:00:00 2001 From: Gato Date: Sun, 7 Jun 2026 11:02:16 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20pre-commit=20hook=20=E2=80=94=20pull?= =?UTF-8?q?=20--rebase=20+=20tests=20avant=20chaque=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .githooks/pre-commit | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 .githooks/pre-commit 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