diff --git a/rollover/review.sh b/rollover/review.sh index e459832..61ae157 100755 --- a/rollover/review.sh +++ b/rollover/review.sh @@ -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"