feat(zsh): ghsq/ghrb land you on updated base when your branch merges - #330
Merged
Conversation
When you squash/rebase-merge the PR of the branch you're currently standing on, gh's --delete-branch moves HEAD off the deleted local branch but does NOT pull, leaving the base branch behind origin. Capture the current branch's PR number before merging (gh moves HEAD during --delete-branch, so a post-merge `gh pr view` with no arg would resolve the base branch's PR instead), then after the batch completes switch to the base branch and `git pull --ff-only` — but only if that PR is authoritatively MERGED. This no-ops when you merge only other people's PRs or skip your own at the confirm prompt, and skips the switch when gh already moved you to base (pull-only). Wired into both the multi-select picker and the `ghsq 123` arg form. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AY6JEGvv5bS7Tvr8acE5P
Contributor
|
| Status | Count |
|---|---|
| 🔍 Total | 170 |
| ✅ Successful | 160 |
| ⏳ Timeouts | 0 |
| 🔀 Redirected | 0 |
| 👻 Excluded | 9 |
| ❓ Unknown | 0 |
| 🚫 Errors | 1 |
Errors per input
Errors in exact_dot_claude/docs/prds/daily-catchup.PRD.md
- [404] https://docs.anthropic.com/claude-code/commands | Failed: Network error: Not Found
Full Github Actions output
Please fix the broken links before merging.
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
When you
ghsq/ghrb-merge the PR of the branch you're currently standing on, you now end up on the (freshly pulled) base branch instead of a stale local base.Why
gh pr merge --delete-branchalready moves HEAD off the deleted local branch, but it does not pull — so the base branch is left behindoriginright after merging your own PR. Previously you'd land on an out-of-datemain(or wherever the PR targeted) and have togit pullby hand.How
_gh_current_pr— capture the current branch's PR number before the merge. This ordering is load-bearing:--delete-branchmoves HEAD during the merge, after which a no-arggh pr viewwould resolve the base branch's PR, not yours._gh_home_if_merged— after the batch completes, query that PR's state and base; only if it's authoritativelyMERGEDdo wegit switchto the base branch andgit pull --ff-only. Gating onMERGEDmeans it silently no-ops when you merge only other people's PRs or skip your own at the confirm prompt. If gh already moved you to base, it skips the switch and just pulls.ghsq 123arg form, for bothghsq(squash) andghrb(rebase).Verification
zsh -non the rendered~/.zshrc(viachezmoi cat) — syntax clean.setopt extended_glob(nobad patterntrap).gh/gitacross four cases: PR still OPEN → no-op; MERGED on feature branch → switch + pull; MERGED already on base → pull only; empty PR → no-op.🤖 Generated with Claude Code