From c87dbbf4b604ae1bc49a6bc797a6da11e6990974 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sun, 22 Mar 2026 18:23:56 +0100 Subject: [PATCH] chore(config): add pre-push hook for GDScript and Rust linting Runs GDScript parse check (headless Godot) and Rust lint (clippy + fmt --check) before every push. Catches type inference errors and formatting issues that code reviews missed in sprint 28. Uses the existing .config/hooks/ infrastructure (core.hooksPath). Co-Authored-By: Claude Opus 4.6 --- .config/hooks/pre-push | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 .config/hooks/pre-push diff --git a/.config/hooks/pre-push b/.config/hooks/pre-push new file mode 100755 index 000000000..802ef617a --- /dev/null +++ b/.config/hooks/pre-push @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Pre-push hook: lint GDScript and Rust before pushing. +# Installed via: git config core.hooksPath .config/hooks +set -euo pipefail + +REPO_ROOT="$(git rev-parse --show-toplevel)" +ERRORS=0 + +echo "pre-push: running lint checks..." + +# --- GDScript lint (headless Godot parse check) --- +GODOT="${GODOT:-godot}" +if command -v "$GODOT" >/dev/null 2>&1; then + echo "pre-push: checking GDScript..." + SCRIPT_ERRORS=$("$GODOT" --headless --path "$REPO_ROOT/client" --quit 2>&1 | grep -ci "SCRIPT ERROR" || true) + if [ "$SCRIPT_ERRORS" -gt 0 ]; then + echo "pre-push: FAIL — $SCRIPT_ERRORS GDScript error(s) found" + "$GODOT" --headless --path "$REPO_ROOT/client" --quit 2>&1 | grep -i "SCRIPT ERROR" + ERRORS=$((ERRORS + 1)) + else + echo "pre-push: GDScript — OK" + fi +else + echo "pre-push: WARNING — Godot not found, skipping GDScript lint" +fi + +# --- Rust lint (clippy + fmt) --- +if command -v cargo >/dev/null 2>&1 && [ -d "$REPO_ROOT/server" ]; then + echo "pre-push: checking Rust (clippy)..." + if ! (cd "$REPO_ROOT/server" && cargo clippy -- -D warnings 2>&1); then + ERRORS=$((ERRORS + 1)) + else + echo "pre-push: clippy — OK" + fi + + echo "pre-push: checking Rust (fmt)..." + if ! (cd "$REPO_ROOT/server" && cargo fmt --check 2>&1); then + ERRORS=$((ERRORS + 1)) + else + echo "pre-push: fmt — OK" + fi +else + echo "pre-push: WARNING — cargo not found or server/ missing, skipping Rust lint" +fi + +if [ "$ERRORS" -gt 0 ]; then + echo "" + echo "pre-push: $ERRORS check(s) failed. Push aborted." + echo " Fix the errors above, then try again." + exit 1 +fi + +echo "pre-push: all checks passed."