38 lines
1.5 KiB
Bash
Executable File
38 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# CHECK -- daily commit census (Extract lane). Exit 0 iff the committed
|
|
# daily-commit-census.csv is a byte-identical re-derivation from git at the rev
|
|
# the committed extraction_manifest.json pins. Independent of the extractor --
|
|
# pure bash + git + coreutils (sort/uniq/awk), no Python.
|
|
set -u
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
|
|
SCRIPT_DIR="$(pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
OUT="$REPO_ROOT/wizard-work/ledger/2026-11-04-daily-commit-census/daily-commit-census.csv"
|
|
MANIFEST="$REPO_ROOT/wizard-work/ledger/2026-11-04-daily-commit-census/extraction_manifest.json"
|
|
|
|
test -s "$OUT" || { echo "FAIL: CSV missing or empty: $OUT" >&2; exit 1; }
|
|
test -s "$MANIFEST" || { echo "FAIL: manifest missing: $MANIFEST" >&2; exit 1; }
|
|
|
|
HEAD_FULL="$(sed -n 's/.*"head_full": "\([^"]*\)".*/\1/p' "$MANIFEST")"
|
|
test -n "$HEAD_FULL" || { echo "FAIL: no head_full in manifest" >&2; exit 1; }
|
|
|
|
tmp="$(mktemp)"
|
|
trap 'rm -f "$tmp"' EXIT
|
|
|
|
{
|
|
echo "date,commits"
|
|
git -C "$REPO_ROOT" log --date=short --pretty=format:%ad "$HEAD_FULL" | sort | uniq -c | awk '{print $2 "," $1}' | sort
|
|
sum="$(git -C "$REPO_ROOT" log --date=short --pretty=format:%ad "$HEAD_FULL" | sort | uniq -c | awk '{s += $1} END {print s}')"
|
|
echo "TOTAL,$sum"
|
|
} > "$tmp"
|
|
|
|
if cmp -s "$OUT" "$tmp"; then
|
|
echo "PASS: daily-commit-census.csv re-derives from git at pinned head $HEAD_FULL"
|
|
exit 0
|
|
fi
|
|
|
|
echo "FAIL: daily-commit-census.csv differs from re-derivation at pinned head $HEAD_FULL" >&2
|
|
diff -u "$OUT" "$tmp" >&2 || true
|
|
exit 1
|