Repository navigation
fix(gh): deduplicate watched PR checks - #3542
Conversation
Signed-off-by: Ruiming Zhao <[email protected]>
e2cf6c6 to
656a864
Compare
`gh pr checks` spells a pending bucket `pending`, never `*`, and prints five tab-separated fields with the description last. The transition test used a shape gh does not emit; the new case carries the trailing description column and a pending row that resolves across polls. Co-Authored-By: Claude Opus 5 <[email protected]>
KuSh
left a comment
There was a problem hiding this comment.
Round 1 of 3 — APPROVED, follow-up filed
Claim: dedupe gh pr checks --watch poll snapshots so each check is counted once, at its latest status.
Scope: accept (round 1, frozen). Two other open PRs touch gh_cmd.rs nearby — #1122 (the RunOptions line just above) and #4000 (the identifier parse inside pr_checks). Neither touches format_pr_checks, and both merge cleanly with this; #3542 can land independently.
Ran: real gh 2.46.0 locally and 2.100.0 in Docker, LC_ALL=C — green / red / live-pending / missing-PR / --required / --json / --watch, develop 5626e94a vs this PR merged onto it.
The decisive case is a live 25-poll --watch, captured against #3857 while its CI was actually running, so the pending→pass transitions are real rather than synthetic (347 lines, 30,794 B):
develop: [ok] Passed: 254 [pending] Pending: 43 <- 11 checks
this PR: [ok] Passed: 11 [FAIL] Failed: 0 <- correct
That is 99.8% against the 20% floor (CONTRIBUTING.md). Non-watch output is byte-identical to develop, exit codes 0/1/8 all propagate, and the error paths are unchanged.
CI @83f87f92: green.
Worth recording: the two earlier CI runs on 656a8640 showed as failure, but both had zero jobs and no logs — they were action_required runs that expired without ever executing. This PR had never been built. The fixup push created a fresh run, which I approved; that is the first real CI this branch has had.
Blocks merge (0, frozen at round 1)
Nothing. No content loss, no wrong answer, no regression against develop.
Optional — closed by fixup 83f87f92
The transition test used "Lint\t*\t\t…". Real gh spells a pending bucket pending, never *, and emits five tab-separated fields with the description last — I checked 92 real rows across 9 PRs plus the 347-line watch capture: zero *, zero empty link fields. The "*" arm itself is harmless dead code and I left it alone; the fixup only corrects the fixture and adds a case with the real five-field shape. Mutation-checked: disabling the dedup fails 3 of the 4 tests, the new one included.
Filed as follow-up
- #4021 —
format_pr_checksdrops every bucket that is notpass/fail/pending, soskippingandcancelledrows vanish and the totals do not add up (real #3982: 8+2 reported for 15 checks). Pre-existing — the old substring implementation dropped the same rows, verified on #1122 — so it is not a regression here and does not hold this up. This PR is the natural base for the fix.
Checked and correct — no need to re-verify
- Output format is byte-identical between
gh2.46.0 and 2.100.0, so the new exact-match parser is not brittle across versions. --jsonis passed through untouched (has_json_flagroutes it to passthrough atgh_cmd.rs:194) — confirmed by replaying realgh2.100 JSON through both binaries.- Each of the three added tests bites under targeted mutation.
Hypotheses built and dropped
- Format drift on newer
gh— the exact-match parser looked brittle next to the old substring matching, but 2.100 emits the identical format. - Empty
linkfield splitting one check into two entries across polls — 0 of 92 real rows have one. - Red PRs showing the fix — they cannot today:
early_exit_on_failuresends a non-zero exit down the raw path, so the benefit on failing runs only appears once #1122 lands. Both are needed for the red case; neither blocks the other.
Next
Nothing — approving. Fixup 83f87f92 pushed: corrects the test fixtures to gh's real row shape and adds a five-field case.
Rounds: 1/3. Threads: 0 open, 0 resolved.
Summary
gh pr checks --watchcan append each polling snapshot when its output is captured instead of sent to a TTY. The formatter was counting everypassandfailrow, so repeated snapshots inflated the totals.This change parses the tab-separated check rows, keeps the latest status for each check identity, and summarizes the deduplicated results. Checks with the same name but different links remain separate, and the final failed rows are still shown.
Fixes #3541
Testing
cargo fmt --all --checkcargo clippy --all-targetscargo test --bin rtk format_pr_checks(3 passed)cargo run --quiet -- gh pr checks 3540 --repo rtk-ai/rtkThe full
cargo testsuite was also run. It produced 2,557 passing tests, with 16 existing process-test failures because their Unix command dependencies are unavailable in this Windows environment; none of those failures involvegh_cmd.rs.