feat(prs): diff breakdown for each PR, shown in the header PR pill #50
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/pr-breakdown"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ports sweatshop's PR breakdown. Every PR a thread opens now records how its diff splits across Generated / Tests / Docs / Migrations / Config / Code. The header PR pill shows the totals, and opens a list of every PR plus a combined category table.
What changed
lib/diff-breakdown.ts(new, pure, tested). Ported from sweatshop: agit diff --numstat -zparser (renames keep the new path, binaries count 0), first-match-wins categories, andmergeBreakdowns. Categories are tuned to tansweat:pnpm-lock.yaml,*.lock,**/routeTree.gen.ts,docs/vendor/**,*.snap*.test.*,*.spec.*,__tests__/,fixtures/,*.fixture.*docs/**,*.md,*.mdxserver/db.ts, so matching that file would count real code as migrations. A comment says so, and empty categories don't show.*.config.*,package.json,pnpm-workspace.yaml,tsconfig*.json,.forgejo/**,Containerfile*,patches/**create_prrecords it. After the PR opens, a separatedeps.once('diff-breakdown')step runsgit diff --numstat -z origin/<base>...HEAD.<base>was already fetched in an earlier step, and a replay returns the recorded value. It's best-effort: if numstat fails, the result has nobreakdownand the PR still succeeds. The result contract indocs/architecture/git.mdis updated.lib/prs.ts.ThreadPRgains an optionalbreakdown, andtitletaken from the call's input.N files +A −D. Clicking opens a popover: one row per PR (live state dot,owner/repo#n, title, +/−, link), then the category table with a Total. A lone PR with no stats still links straight out. This addscomponents/ui/popover.tsx, the shadcn popover on the already-pinnedradix-ui, so no new dependency.Verification
pnpm typecheckandpnpm testpass (1331 passed, up from 1295). The new tests cover the parser, the categories, merging,create_prwith and without a numstat failure, andprsFromMessagesreading title and breakdown.git diff --numstat -zfor the actual #47, #48 and #49 diffs. The totals matchgit --shortstat, and #48's split matches Forgejo's own breakdown (Docs 1 +3, Code 27 +97 −61).git()helper's.trim()only strips the trailing NUL.Limits
create_pr. The first real PR will be the end-to-end check.Screenshots