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)); }
|
||||
|
||||
Reference in New Issue
Block a user