fix(config): skip GDScript/Rust lint in pre-push when no changes in those dirs

Pre-push hook now detects which directories have changes in the push
range. Skips GDScript checks when no client/ files changed, skips Rust
checks when no server/ files changed. Prevents worktree cache issues
from blocking data-only pushes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 22:39:41 +01:00
co-authored by Claude Opus 4.6
parent 8a3c5af842
commit 77793384a7
+20 -5
View File
@@ -8,9 +8,22 @@ ERRORS=0
echo "pre-push: running lint checks..."
# --- GDScript parse check (headless Godot) ---
# --- Detect which directories have changes vs remote ---
BRANCH=$(git branch --show-current)
REMOTE_REF="origin/$BRANCH"
if git rev-parse --verify "$REMOTE_REF" >/dev/null 2>&1; then
CLIENT_CHANGED=$(git diff --name-only "$REMOTE_REF"..HEAD -- client/ 2>/dev/null | wc -l)
SERVER_CHANGED=$(git diff --name-only "$REMOTE_REF"..HEAD -- server/ 2>/dev/null | wc -l)
else
# New branch, no remote ref — check everything
CLIENT_CHANGED=1
SERVER_CHANGED=1
fi
GODOT="${GODOT:-godot}"
if command -v "$GODOT" >/dev/null 2>&1; then
if [ "$CLIENT_CHANGED" -eq 0 ]; then
echo "pre-push: no client/ changes in push — skipping GDScript checks"
elif 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
@@ -25,7 +38,7 @@ else
fi
# --- GDScript lint (gdlint static analysis) — advisory only until codebase is clean ---
if command -v gdlint >/dev/null 2>&1; then
if [ "$CLIENT_CHANGED" -gt 0 ] && 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
@@ -36,7 +49,7 @@ if command -v gdlint >/dev/null 2>&1; then
fi
# --- GDScript format check (gdformat) — advisory only until codebase is clean ---
if command -v gdformat >/dev/null 2>&1; then
if [ "$CLIENT_CHANGED" -gt 0 ] && 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
@@ -47,7 +60,9 @@ if command -v gdformat >/dev/null 2>&1; then
fi
# --- Rust lint (clippy + fmt) ---
if command -v cargo >/dev/null 2>&1 && [ -d "$REPO_ROOT/server" ]; then
if [ "$SERVER_CHANGED" -eq 0 ]; then
echo "pre-push: no server/ changes in push — skipping Rust checks"
elif 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))