fix(lint): fail loudly on a nonexistent REPO_ROOT in check-vale-style-sync.sh
A bad or stale REPO_ROOT argument fell through to the "neither copy present" no-op guard and exited 0 — the exact "clean result can mean nothing was checked" anti-pattern this PR spent multiple review rounds eliminating elsewhere. That guard exists for a repo that legitimately has no kyberforge plugin installed, not for a typo'd path. Only the documented manual-invocation mode was affected: the shipped pre-push hook always calls this script with zero args, which resolves via `git rev-parse --show-toplevel` and is always valid inside a repo. Added a regression test asserting a nonexistent REPO_ROOT exits non-zero. Refs: #85
This commit is contained in:
@@ -10,11 +10,17 @@ set -euo pipefail
|
||||
# only one of the two. Run from repo root or pass REPO_ROOT as arg.
|
||||
|
||||
REPO_ROOT="${1:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
|
||||
# A nonexistent REPO_ROOT must fail loudly, not fall through to the "neither
|
||||
# copy present" no-op below — that guard exists for a repo that legitimately
|
||||
# has no kyberforge plugin installed, not for a typo'd or stale path, and a
|
||||
# clean exit 0 here would read as "checked, in sync" when nothing ran at all.
|
||||
if [[ ! -d "$REPO_ROOT" ]]; then
|
||||
echo "Vale style sync check failed: REPO_ROOT '$REPO_ROOT' is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
# Absolutized because the glob probe below `cd`s into a scratch tree, where a
|
||||
# relative --config path would stop resolving.
|
||||
if [[ -d "$REPO_ROOT" ]]; then
|
||||
REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
|
||||
fi
|
||||
REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
|
||||
FAIL=0
|
||||
|
||||
err() { echo " FAIL: $1" >&2; FAIL=$((FAIL + 1)); }
|
||||
|
||||
@@ -123,6 +123,19 @@ else
|
||||
fail "exited non-zero when skill-audit/agent-audit are simply absent"
|
||||
fi
|
||||
|
||||
# --- 5b. Exits 1 when REPO_ROOT does not exist ---
|
||||
# A nonexistent path used to fall through to the "neither copy present" no-op
|
||||
# (test 5 above) and exit 0 — indistinguishable from a real, verified in-sync
|
||||
# result. That guard is for a repo legitimately missing kyberforge, not a
|
||||
# typo'd or stale path.
|
||||
echo ""
|
||||
echo "--- exits 1 when REPO_ROOT does not exist ---"
|
||||
if bash "$SCRIPT" "/nonexistent/path/$(date +%s)-$$" > /dev/null 2>&1; then
|
||||
fail "exited 0 for a nonexistent REPO_ROOT — expected exit 1"
|
||||
else
|
||||
pass "exits non-zero for a nonexistent REPO_ROOT"
|
||||
fi
|
||||
|
||||
# --- 6. Exits 1 when only one of the two copies is present ---
|
||||
# The no-op guard used `||`, so a single missing copy also exited 0 — a deleted
|
||||
# or renamed copy passed the sync check silently.
|
||||
|
||||
Reference in New Issue
Block a user