Files
settled-reach/.config/hooks/pre-push
T
jpmschweitzerandClaude Opus 4.6 4d1a29bcc1 chore(config): add gdlint + gdformat + cargo-deny to pre-push hook
Pre-push now runs 6 checks:
- GDScript: parse check, gdlint (static analysis), gdformat (style)
- Rust: clippy, fmt, cargo deny (license/advisory/deps)
All tools degrade gracefully if not installed.

Also files Q-065 through Q-080: shooting mechanics, procedural terrain,
cloth sim, vehicle physics, PathMesh3D, NobodyWho vs voice pipeline,
BitTorrent distribution, BehaviourToolkit patterns, screenshot manager,
RichText3D, DeformableMesh, GridMapLayer, mod loader, god rays,
Steam multiplayer, CityCrafter3D, planet generator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 19:06:03 +01:00

86 lines
3.1 KiB
Bash
Executable File

#!/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 parse check (headless Godot) ---
GODOT="${GODOT:-godot}"
if command -v "$GODOT" >/dev/null 2>&1; then
echo "pre-push: checking GDScript (parse)..."
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 parse — OK"
fi
else
echo "pre-push: WARNING — Godot not found, skipping GDScript parse check"
fi
# --- GDScript lint (gdlint static analysis) — advisory only until codebase is clean ---
if command -v gdlint >/dev/null 2>&1; then
echo "pre-push: checking GDScript (gdlint — advisory)..."
LINT_COUNT=$(gdlint "$REPO_ROOT/client/scripts/" "$REPO_ROOT/client/ui/" 2>&1 | grep -c "Error:" || true)
if [ "$LINT_COUNT" -gt 0 ]; then
echo "pre-push: gdlint — $LINT_COUNT issue(s) (advisory, not blocking)"
else
echo "pre-push: gdlint — OK"
fi
fi
# --- GDScript format check (gdformat) — advisory only until codebase is clean ---
if command -v gdformat >/dev/null 2>&1; then
echo "pre-push: checking GDScript (gdformat — advisory)..."
FORMAT_COUNT=$(gdformat --check "$REPO_ROOT/client/scripts/" "$REPO_ROOT/client/ui/" 2>&1 | grep -c "would reformat" || true)
if [ "$FORMAT_COUNT" -gt 0 ]; then
echo "pre-push: gdformat — $FORMAT_COUNT file(s) need formatting (advisory, not blocking)"
else
echo "pre-push: gdformat — OK"
fi
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
# --- Rust dependency audit (cargo deny) — requires deny.toml config ---
if command -v cargo-deny >/dev/null 2>&1 && [ -f "$REPO_ROOT/server/deny.toml" ]; then
echo "pre-push: checking Rust (cargo deny)..."
if ! (cd "$REPO_ROOT/server" && cargo deny check 2>&1); then
ERRORS=$((ERRORS + 1))
else
echo "pre-push: cargo deny — OK"
fi
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."