Commit 233d1634ad22c7de8de224155c7112ad8c4697f2

Authored by zichun
1 parent cd2d8d08

chore(scripts): scope test gate stack detection to tracked files

Untracked WIP directories (e.g. unfinished frontend/) were triggering
HAS_FRONTEND=1 via bare `[ -d frontend ]`, causing the pre-push gate
to lint/build code that isn't part of the push. Require non-empty
`git ls-files -- <dir>` so detection follows tracked content, matching
the CLAUDE.md rule that the gate covers current module + completed
modules only.
Showing 1 changed file with 3 additions and 3 deletions
scripts/test.sh
@@ -21,9 +21,9 @@ if [ -n &quot;${EXTRA_PATH:-}&quot; ]; then @@ -21,9 +21,9 @@ if [ -n &quot;${EXTRA_PATH:-}&quot; ]; then
21 export PATH="$EXTRA_PATH:$PATH" 21 export PATH="$EXTRA_PATH:$PATH"
22 fi 22 fi
23 23
24 -# Stack detection (runtime, mode-agnostic)  
25 -HAS_BACKEND=0; [ -d backend ] && HAS_BACKEND=1  
26 -HAS_FRONTEND=0; [ -d frontend ] && HAS_FRONTEND=1 24 +# Stack detection: tracked content only — untracked WIP must not gate pushes
  25 +HAS_BACKEND=0; [ -d backend ] && [ -n "$(git ls-files -- backend 2>/dev/null)" ] && HAS_BACKEND=1
  26 +HAS_FRONTEND=0; [ -d frontend ] && [ -n "$(git ls-files -- frontend 2>/dev/null)" ] && HAS_FRONTEND=1
27 if [ $HAS_BACKEND -eq 0 ] && [ $HAS_FRONTEND -eq 0 ]; then 27 if [ $HAS_BACKEND -eq 0 ] && [ $HAS_FRONTEND -eq 0 ]; then
28 echo "[test.sh] FATAL: neither backend/ nor frontend/ exists" >&2 28 echo "[test.sh] FATAL: neither backend/ nor frontend/ exists" >&2
29 exit 1 29 exit 1