Files

28 lines
1.2 KiB
Bash

#!/bin/bash
# CHECK-author-census -- verify 2026-11-02-author-census.csv against live git output.
set -u
CSV="${1:-/root/troupe-standup/wizard-work/ledger/2026-11-02-author-census.csv}"
[ -d /root/troupe-standup/.git ] || { echo "CANNOT GRADE: not a git repo"; exit 2; }
[ -f "$CSV" ] || { echo "CANNOT GRADE: missing $CSV"; exit 2; }
# Header (CSV files in this tree use CRLF line endings; strip \r)
head -n1 "$CSV" | tr -d '\r' | grep -qx 'rank,author,commits' || { echo "FAIL header"; exit 1; }
# Row count (exactly 20 data rows)
n=$(tail -n +2 "$CSV" | tr -d '\r' | wc -l)
[ "$n" -eq 20 ] || { echo "FAIL row count $n"; exit 1; }
# Top author in artifact must match the live top author and its commit count
top_artifact=$(head -n2 "$CSV" | tail -n1 | cut -d, -f2 | tr -d '\r')
live_top=$(git -C /root/troupe-standup log --format='%an' | sort | uniq -c | sort -rn | head -n1)
live_n=$(printf '%s\n' "$live_top" | awk '{print $1}')
live_top_name=$(printf '%s\n' "$live_top" | awk '{print $2}')
[ "$top_artifact" = "$live_top_name" ] || { echo "FAIL top author $top_artifact vs $live_top_name"; exit 1; }
[ "$live_n" -eq 557 ] || { echo "FAIL top commit count $live_n"; exit 1; }
echo "OK rows=20 top=$top_artifact $live_n commits"
exit 0