Skip to content

feat(zsh): ghsq/ghrb land you on updated base when your branch merges - #330

Merged
laurigates merged 1 commit into
mainfrom
feat/ghsq-ghrb-home-on-merge
Jul 17, 2026
Merged

feat(zsh): ghsq/ghrb land you on updated base when your branch merges#330
laurigates merged 1 commit into
mainfrom
feat/ghsq-ghrb-home-on-merge

Conversation

@laurigates

Copy link
Copy Markdown
Owner

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-branch already moves HEAD off the deleted local branch, but it does not pull — so the base branch is left behind origin right after merging your own PR. Previously you'd land on an out-of-date main (or wherever the PR targeted) and have to git pull by hand.

How

  • _gh_current_pr — capture the current branch's PR number before the merge. This ordering is load-bearing: --delete-branch moves HEAD during the merge, after which a no-arg gh pr view would 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 authoritatively MERGED do we git switch to the base branch and git pull --ff-only. Gating on MERGED means 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.
  • Wired into both the multi-select picker and the ghsq 123 arg form, for both ghsq (squash) and ghrb (rebase).

Verification

  • zsh -n on the rendered ~/.zshrc (via chezmoi cat) — syntax clean.
  • Tab-split parameter expansions verified under setopt extended_glob (no bad pattern trap).
  • Control-flow tested with stubbed gh/git across 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

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
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Broken Links Detected

Summary

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


Please fix the broken links before merging.

@laurigates
laurigates merged commit ef40151 into main Jul 17, 2026
7 of 8 checks passed
@laurigates
laurigates deleted the feat/ghsq-ghrb-home-on-merge branch July 17, 2026 17:16
@laurigates
laurigates restored the feat/ghsq-ghrb-home-on-merge branch July 17, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant