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 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 18:23:56 +01:00
co-authored by Claude Opus 4.6
parent acb1119b2a
commit c87dbbf4b6
+53
View File
@@ -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."