feat(zsh): narrate ghsq/ghrb's post-merge branch switch - #355
Merged
Conversation
The go-home helper relocated you to the base branch with a single line
("#268 was merged — on main, pulling"), printed *after* the switch. That
left two things unexplained.
First, the guard is "this branch's PR is MERGED", not "…was merged by
this run" — so it also fires when you were already standing on a branch
merged days ago, while merging unrelated PRs. Correct (the branch is
stale either way), but it reads as a non-sequitur when the PR numbers on
screen are not the one named in the message.
Second, git's own "Your branch is behind 'origin/main'" chatter landed
*before* the explanation, so the first thing you saw was a consequence.
Now the move is narrated before it happens:
⇣ what feat/foo → main — git switch main && git pull --ff-only
why this branch's PR #268 is MERGED (already merged before this
run, 2026-08-06 14:22Z) — its commits are already on main
kept local branch feat/foo — delete with git branch -d feat/foo
"by this run" vs "before this run" is decided by membership in the set of
PR numbers the invocation acted on (passed in by ghsq/ghrb), never by
comparing clocks — local-vs-GitHub skew would misdate a merge landing
seconds either side of the run. The picker only lists OPEN PRs, so
"was selected AND is now MERGED" means this run merged it. mergedAt
prints either way as the ground truth behind the label.
The "kept" line answers the question the old output invited: the local
branch is never deleted here, only the remote-tracking ref is pruned.
Verified with a stubbed-gh/git harness over ten paths: merged-by-this-run,
merged-earlier, empty acted set, local branch absent, already on base,
switch refused (exit 1, stays put), PR still OPEN and no-PR (both silent),
mergedAt missing, and detached HEAD — under `setopt extended_glob`, which
the interactive shell has set.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mbyb2ptbDET8P11pPyqToe
Contributor
|
| Status | Count |
|---|---|
| 🔍 Total | 170 |
| ✅ Successful | 160 |
| ⏳ Timeouts | 0 |
| 🔀 Redirected | 0 |
| 👻 Excluded | 9 |
| ❓ Unknown | 0 |
| 🚫 Errors | 1 |
Errors per input
Errors in docs/macos-automation.md
- [ERROR] https://macos-defaults.com/ | Failed: Network error: error sending request for url (https://macos-defaults.com/)
Full Github Actions output
Please fix the broken links before merging.
Contributor
|
🤖 Claude analyzed the CI failures but determined no code changes are needed. Failed workflow: https://github.com/laurigates/dotfiles/actions/runs/31163996781 This may indicate:
Please review the failure logs manually. |
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.
What
ghsq/ghrbrelocate you to the base branch when the branch you're standing on has a merged PR. That move was announced by one line, printed after it happened:It now explains itself first:
Why
Behaviour is unchanged — the gate was already correct (
state == MERGED, read authoritatively from the API). What was missing is transparency about which branch is being left, on whose authority, and what happened to it.Two specific gaps this closes:
git switchprintsYour branch is behind 'origin/main'…itself, and the old message came after it — so the first thing you saw was a consequence of an unexplained action.what/whynow print before the switch, and are therefore also present when the switch fails.The
keptline answers the question the old output invited: nothing local is deleted here, only the remote-tracking ref gets pruned by the fetch.How
_gh_home_if_mergedtakes a second argument: the PR numbers this invocation acted on.ghsq/ghrbpass the picker's TSV column (or the single arg-form number).mergedAtagainst a locally captured start time would misdate merges landing seconds either side of the run under local-vs-GitHub skew. The picker only ever lists OPEN PRs, so "was selected AND is now MERGED" means this run merged it.mergedAtprints either way as the ground truth behind the label.Testing
Behavioural harness with stubbed
gh/gitover ten paths, undersetopt extended_glob(which the interactive shell has set, and which is what makes#-in-pattern bugs surface):keptlineexit 1, stays putmergedAtmissingkeptlinePlus
zsh -non the rendered~/.zshrc, andchezmoi diffreviewed pre-apply to confirm no target-side drift was clobbered.🤖 Generated with Claude Code
https://claude.ai/code/session_01Mbyb2ptbDET8P11pPyqToe