Fix review.sh inventing 12 removals that the prune never makes
It round-tripped the pruned text through a shell variable, and command substitution strips every trailing newline while printf added exactly one back, so any file whose pruned output ended in more than one blank line diffed against a reshaped copy of itself. Comparing files directly instead brings review.sh to 270 removals across 118 files, matching validate.py, which derives the same number from the drop set rather than from a diff. The counting was wrong too: a removed `- [x] foo` is `-- [x] foo` in a unified diff, so the `^-[^-]` pattern skipped every checkbox it was meant to be counting. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PU5ZFfQFtDTFqqhvMTWdGH
This commit is contained in:
1 parent
1053310d32
commit
caa367feb2
1 file changed
+16
-6
+16
-6
@@ -1,17 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Regenerate the whole-corpus prune diff. The plan requires reviewing this
|
||||
# before the timer runs, and again after any change to the rule.
|
||||
# Regenerate the whole-corpus prune diff. The plan gates the timer on reviewing
|
||||
# this, and the same gate should be re-runnable after any change to the rule.
|
||||
set -eu
|
||||
|
||||
NOTES="${1:-$HOME/docs/notes/todo}"
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
OUT="${OUT:-$HOME/todo-prune-review.diff}"
|
||||
|
||||
tmp=$(mktemp)
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
|
||||
: > "$OUT"
|
||||
files=0
|
||||
for f in "$NOTES"/*.md; do
|
||||
p=$(python3 "$HERE/prune.py" "$f")
|
||||
if [ "$p" != "$(cat "$f")" ]; then
|
||||
printf '%s\n' "$p" | diff -u --label "$f (now)" --label "$f (pruned)" "$f" - >> "$OUT" || true
|
||||
# Compare files rather than shell strings: command substitution eats
|
||||
# trailing newlines and would invent differences that are not there.
|
||||
python3 "$HERE/prune.py" "$f" > "$tmp"
|
||||
if ! cmp -s "$f" "$tmp"; then
|
||||
diff -u --label "$f (now)" --label "$f (pruned)" "$f" "$tmp" >> "$OUT" || true
|
||||
files=$((files + 1))
|
||||
fi
|
||||
done
|
||||
echo "$OUT: $(grep -c '^-[^-]' "$OUT" || true) lines removed across $(grep -c '^---' "$OUT" || true) files"
|
||||
|
||||
all=$(grep -c '^-' "$OUT" || true)
|
||||
hdr=$(grep -c '^--- ' "$OUT" || true)
|
||||
echo "$OUT: $((all - hdr)) lines removed across $files files"
|
||||
Reference in new issue
Block a user