fix(scripts): check links in tracked files, not everything on disk
Publish Documentation / Build & publish docs to gitea-pages (push) Canceled after 0s
🏗️ Build and Test JellyTau / Run Tests (push) Failing after 17m30s
🏗️ Build and Test JellyTau / Android Compile Check (push) Skipped
Traceability Validation / Check Requirement Traces (push) Successful in 19s
Publish Documentation / Build & publish docs to gitea-pages (push) Canceled after 0s
🏗️ Build and Test JellyTau / Run Tests (push) Failing after 17m30s
🏗️ Build and Test JellyTau / Android Compile Check (push) Skipped
Traceability Validation / Check Requirement Traces (push) Successful in 19s
The prune list was wrong three times running: it walked the scratch worktrees under .claude/, then makepkg's vendored cargo registry under packaging/arch/src/, reporting a dependency's broken README as if it were ours. Every one of those directories is already git-ignored, so asking git for the file list makes the exclusion rule the same one the repo already maintains — and it cannot drift the way a hand-kept prune list did. It also makes the script do what its header always said it did: check tracked markdown. Untracked-but-unignored files are included on purpose, so a new doc is checked before it is committed rather than after. The find(1) path stays as a fallback for a non-git checkout. CI was unaffected — a fresh checkout has none of those directories — but the local gate cried wolf, which is how a gate stops being read.
This commit is contained in:
@@ -48,6 +48,9 @@ cd "$(dirname "$0")/.."
|
|||||||
|
|
||||||
# Generated, vendored or build-output trees. Their markdown is not authored here
|
# Generated, vendored or build-output trees. Their markdown is not authored here
|
||||||
# and their link targets are not ours to fix.
|
# and their link targets are not ours to fix.
|
||||||
|
#
|
||||||
|
# Only consulted when this is NOT a git checkout — inside one, the tracked-file
|
||||||
|
# list does this job and does not need maintaining. Kept for the tarball case.
|
||||||
EXCLUDES=(
|
EXCLUDES=(
|
||||||
"./node_modules/*"
|
"./node_modules/*"
|
||||||
"./.svelte-kit/*"
|
"./.svelte-kit/*"
|
||||||
@@ -81,14 +84,33 @@ is_generated() {
|
|||||||
|
|
||||||
echo "🔎 Checking relative markdown links resolve to files on disk…"
|
echo "🔎 Checking relative markdown links resolve to files on disk…"
|
||||||
|
|
||||||
# Build the find(1) prune expression from EXCLUDES.
|
# Ask git which markdown files are ours, rather than walking the filesystem.
|
||||||
find_args=(. )
|
#
|
||||||
for pattern in "${EXCLUDES[@]}"; do
|
# This started as a find(1) with a hand-maintained prune list, and that list was
|
||||||
find_args+=(-path "$pattern" -prune -o)
|
# wrong three times in a row: it walked the scratch worktrees under .claude/,
|
||||||
done
|
# then makepkg's vendored cargo registry under packaging/arch/src/ — each time
|
||||||
find_args+=(-name "*.md" -type f -print)
|
# reporting a dependency's broken README as if it were ours. Every one of those
|
||||||
|
# directories is already git-ignored, so the tracked-file list is the exclusion
|
||||||
mapfile -t md_files < <(find "${find_args[@]}" | sort)
|
# rule, and it cannot drift out of date the way EXCLUDES did. It also matches
|
||||||
|
# what this script always claimed to do.
|
||||||
|
#
|
||||||
|
# Untracked-but-not-ignored files are deliberately included: a new doc added in
|
||||||
|
# a working tree should be checked before it is committed, not after.
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
mapfile -t md_files < <(
|
||||||
|
{ git ls-files -z --cached --others --exclude-standard -- '*.md' | tr '\0' '\n'; } \
|
||||||
|
| sed 's|^|./|' | sort -u
|
||||||
|
)
|
||||||
|
else
|
||||||
|
# Not a git checkout (an exported tarball, say): fall back to walking, with
|
||||||
|
# the prune list below as the only defence.
|
||||||
|
find_args=(. )
|
||||||
|
for pattern in "${EXCLUDES[@]}"; do
|
||||||
|
find_args+=(-path "$pattern" -prune -o)
|
||||||
|
done
|
||||||
|
find_args+=(-name "*.md" -type f -print)
|
||||||
|
mapfile -t md_files < <(find "${find_args[@]}" | sort)
|
||||||
|
fi
|
||||||
|
|
||||||
echo " ${#md_files[@]} markdown files"
|
echo " ${#md_files[@]} markdown files"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user