perf(gitpr): fetch the merge plan in one request, and show progress - #181
Merged
Conversation
Wrapping the gh calls in ui_spinner was the ask; measuring them first changed what the fix should be. Reading the nine fields of the merge plan took nine `gh pr view` calls — 3.44s measured, all of it silent — against 0.47s for one batched read. A spinner makes a wait legible, but not waiting is better, so the batching is the fix and the spinner covers what is left. Also folded in: the separate `gh pr view --json number` existence check was a tenth call saying what the plan read already says by failing, and `gh pr checks` ran twice, once to print and once to decide. The batched fields are joined on U+001F rather than a tab. Tab counts as IFS whitespace, so `read` collapses a run of them and one empty field shifts every later field left — and reviewDecision is empty on any PR nobody reviewed, which is most of them. A tab-separated read would have printed the URL as the review decision. Verified against live gh on #180, where reviewDecision is in fact empty: "Review: none" and the URL both land correctly. The script is launched as its own process by the git menu, so it sources mq-ui.sh itself and falls back to a no-op ui_spinner when the library is not reachable. A missing spinner must not cost you the merge tool. First test coverage this script has had — gitmerge-safe-smoke.sh covers the local-merge sibling, not this one. The fake gh records every invocation, so "one call, not nine" is asserted against behaviour rather than against how the source reads, and the no-TTY guardrail and the declined confirmation are pinned too. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #180: wire
ui_spinnerinto the PR-merge tool. Measuring the calls first changed what the fix should be.The wait was nine round trips, not one slow one
gitpr-merge-safe.shread nine PR fields with nine separategh pr viewcalls, one per field:A spinner makes a wait legible. Not waiting is better. So the batching is the fix and the spinner covers what is left. Two more redundant calls went with it: a separate
gh pr view --json numberexistence check that said what the plan read already says by failing, andgh pr checksrunning twice — once to print, once to decide.Measured end to end against live gh: the whole plan phase now takes 0.99s, spinner included.
The delimiter is load-bearing
The batched fields are joined on U+001F, not a tab. Tab counts as IFS whitespace, so
readcollapses a run of them and one empty field shifts every later field left:reviewDecisionis empty on any PR nobody reviewed, which is most of them — so a tab-separated read would have printed the URL as the review decision. Confirmed against live gh on #180, wherereviewDecisionis in fact empty:joinalso refuses to join null, so nulls map to""first.Sourcing
The git menu launches this script as its own process (
( cd "$CURRENT_REPO" && "$merge_script" )), it never sources it — so the script loadsmq-ui.shitself and falls back to a no-opui_spinnerwhen the library is unreachable. A missing spinner must not cost you the merge tool. Step 6 pins that.Test coverage
First coverage this script has ever had;
gitmerge-safe-smoke.shcovers the local-merge sibling, not this one. It matters here more than most — this is the one script in the repo that can change a remote branch.The fake
ghrecords every invocation, so "one call, not nine" is asserted against behaviour rather than against how the source happens to read. Also pinned: the no-TTY guardrail, that the confirmation can be declined, and that declining meansgh pr mergewas never called.🤖 Generated with Claude Code