#!/bin/bash # List git activity on one day across every repo `locate` knows about. # # Usage: day-in-repos.sh YYYY-MM-DD [git-log-args...] # # Prints commits (by committer date) and reflog entries (pulls, checkouts, # amends: local-only events that `git log` never shows), sorted by local # time. A commit present in several clones/worktrees is printed once, with # every repo it appears in. Extra args go to `git log`, e.g. --author=dckc # to drop bot and upstream commits. set -euo pipefail [[ $# -ge 1 && $1 =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || { sed -n '2,10p' "$0" exit 2 } day=$1 shift next=$(date -d "$day + 1 day" +%F) locate -r '/\.git$' \ | grep "^$HOME/" \ | grep -v -e /node_modules/ -e /.cache/ -e /.cargo/ -e /go/pkg/ \ | while read -r g; do r=${g%/.git} name=${r#"$HOME"/} git -C "$r" log --all --since="$day 00:00" --until="$next 00:00" \ --date=format:%H:%M --format="%cd %h $name %s" "$@" 2>/dev/null || true git -C "$r" reflog --all --date=format:'%F %H:%M' \ --format="%gd $name %gs" 2>/dev/null \ | awk -F'\t' -v day="$day" ' match($1, /\{[0-9-]+ [0-9:]+\}/) { ts = substr($1, RSTART + 1, RLENGTH - 2) if (substr(ts, 1, 10) == day) printf "%s\treflog\t%s\t%s\n", substr(ts, 12), $2, $3 }' || true done \ | awk -F'\t' ' # group by time+hash (reflog rows by time+subject) { key = ($2 == "reflog") ? $1 FS $4 : $1 FS $2 if (!(key in repos)) { order[++n] = key; line[key] = $0 } if (!((key, $3) in seen)) { seen[key, $3] = 1 repos[key] = repos[key] (repos[key] ? " " : "") $3 } } END { for (i = 1; i <= n; i++) { split(line[order[i]], f, FS) printf "%s %-7s %s [%s]\n", f[1], f[2], f[4], repos[order[i]] } }' \ | sort