#!/usr/bin/env python3 """Print old->new commit SHA map by matching subject|author|email|date.""" from __future__ import annotations import subprocess import sys ROOT = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip() def git(*args: str) -> str: return subprocess.check_output(["git", "-C", ROOT, *args], text=True).strip() def signature(commit: str) -> str: return git("log", "-1", "--format=%s|%an|%ae|%ad", commit, "--date=iso-strict") def main() -> int: old_hashes = git("log", "dev-old-linear", "--format=%H").splitlines() new_by_sig: dict[str, str] = {} for h in git("log", "dev", "--format=%H").splitlines(): new_by_sig[signature(h)] = h print("old_sha\tnew_sha\tsubject") for old in reversed(old_hashes): sig = signature(old) new = new_by_sig.get(sig, "") subj = git("log", "-1", "--format=%s", old) print(f"{old[:12]}\t{new[:12] if new else 'NOT_FOUND'}\t{subj}") return 0 if __name__ == "__main__": sys.exit(main())