Skip to content

Commit 63f019e

Browse files
committed
clearer info msg with rebasing over merged PRs
1 parent 0c9615e commit 63f019e

8 files changed

Lines changed: 16 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Pull from remote and do a cascading rebase across the stack.
197197
gh stack rebase [flags] [branch]
198198
```
199199

200-
Fetches the latest changes from `origin`, then ensures each branch in the stack has the tip of the previous layer in its commit history. Rebases branches in order from trunk upward. If a branch's PR has been squash-merged, the rebase automatically switches to `--onto` mode to correctly replay commits on top of the merge target.
200+
Fetches the latest changes from `origin`, then ensures each branch in the stack has the tip of the previous layer in its commit history. Rebases branches in order from trunk upward. If a branch's PR has been merged, the rebase automatically switches to `--onto` mode to correctly replay commits on top of the merge target.
201201

202202
If a rebase conflict occurs, the operation pauses and prints the conflicted files with line numbers. Resolve the conflicts, stage with `git add`, and continue with `--continue`. To undo the entire rebase, use `--abort` to restore all branches to their pre-rebase state.
203203

cmd/rebase.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func runRebase(cfg *config.Config, opts *rebaseOptions) error {
188188
return ErrSilent
189189
}
190190

191-
// Track --onto rebase state for squash-merged branches.
191+
// Track --onto rebase state for merged branches.
192192
needsOnto := false
193193
var ontoOldBase string
194194

@@ -201,7 +201,7 @@ func runRebase(cfg *config.Config, opts *rebaseOptions) error {
201201
base = s.Branches[absIdx-1].Branch
202202
}
203203

204-
// Skip branches whose PRs have already been merged (e.g. via squash).
204+
// Skip branches whose PRs have already been merged.
205205
// Record state so subsequent branches can use --onto rebase.
206206
if br.IsMerged() {
207207
ontoOldBase = originalRefs[br.Branch]
@@ -252,7 +252,7 @@ func runRebase(cfg *config.Config, opts *rebaseOptions) error {
252252
return ErrConflict
253253
}
254254

255-
cfg.Successf("Rebased %s onto %s (squash-merge detected)", br.Branch, newBase)
255+
cfg.Successf("Rebased %s onto %s (adjusted for merged PR)", br.Branch, newBase)
256256
// Keep --onto mode; update old base for the next branch.
257257
ontoOldBase = originalRefs[br.Branch]
258258
} else {
@@ -450,7 +450,7 @@ func continueRebase(cfg *config.Config, gitDir string) error {
450450
return ErrConflict
451451
}
452452

453-
cfg.Successf("Rebased %s onto %s (squash-merge detected)", branchName, newBase)
453+
cfg.Successf("Rebased %s onto %s (adjusted for merged PR)", branchName, newBase)
454454
state.OntoOldBase = state.OriginalRefs[branchName]
455455
} else {
456456
var rebaseErr error

cmd/rebase_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ func TestRebase_CascadeRebase(t *testing.T) {
106106
assert.Contains(t, output, "rebased locally")
107107
}
108108

109-
// TestRebase_SquashMergedBranch_UsesOnto verifies that when b1 has a merged PR,
109+
// TestRebase_MergedBranch_UsesOnto verifies that when b1 has a merged PR,
110110
// it is skipped and b2 uses RebaseOnto with trunk as newBase and b1's original
111111
// SHA as oldBase. b3 also uses --onto (propagation).
112-
func TestRebase_SquashMergedBranch_UsesOnto(t *testing.T) {
112+
func TestRebase_MergedBranch_UsesOnto(t *testing.T) {
113113
s := stack.Stack{
114114
Trunk: stack.BranchRef{Branch: "main"},
115115
Branches: []stack.BranchRef{
@@ -171,7 +171,7 @@ func TestRebase_SquashMergedBranch_UsesOnto(t *testing.T) {
171171
}
172172

173173
// TestRebase_OntoPropagatesToSubsequentBranches verifies that when multiple
174-
// branches are squash-merged, --onto propagates correctly through the chain.
174+
// branches are merged, --onto propagates correctly through the chain.
175175
func TestRebase_OntoPropagatesToSubsequentBranches(t *testing.T) {
176176
s := stack.Stack{
177177
Trunk: stack.BranchRef{Branch: "main"},
@@ -651,7 +651,7 @@ func TestRebase_Continue_RebasesRemainingBranches(t *testing.T) {
651651
}
652652

653653
// TestRebase_Continue_OntoMode verifies the --continue path when UseOnto is
654-
// set (squash-merged branches upstream). With no remaining branches, only
654+
// set (merged branches upstream). With no remaining branches, only
655655
// RebaseContinue runs and the state is cleaned up.
656656
func TestRebase_Continue_OntoMode(t *testing.T) {
657657
s := stack.Stack{

cmd/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func runSync(cfg *config.Config, opts *syncOptions) error {
197197
break
198198
}
199199

200-
cfg.Successf("Rebased %s onto %s (squash-merge detected)", br.Branch, newBase)
200+
cfg.Successf("Rebased %s onto %s (adjusted for merged PR)", br.Branch, newBase)
201201
ontoOldBase = originalRefs[br.Branch]
202202
} else {
203203
var rebaseErr error

cmd/sync_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ func TestSync_PushForceFlagDependsOnRebase(t *testing.T) {
522522
}
523523
}
524524

525-
// TestSync_SquashMergedBranch_UsesOnto verifies that when a squash-merged
525+
// TestSync_MergedBranch_UsesOnto verifies that when a merged
526526
// branch exists in the stack, sync's cascade rebase correctly uses --onto
527527
// to skip the merged branch and rebase subsequent branches onto the right base.
528-
func TestSync_SquashMergedBranch_UsesOnto(t *testing.T) {
528+
func TestSync_MergedBranch_UsesOnto(t *testing.T) {
529529
s := stack.Stack{
530530
Trunk: stack.BranchRef{Branch: "main"},
531531
Branches: []stack.BranchRef{

docs/src/content/docs/reference/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ gh stack rebase [flags] [branch]
223223

224224
Fetches the latest changes from `origin`, then ensures each branch in the stack has the tip of the previous layer in its commit history. Rebases branches in order from trunk upward.
225225

226-
If a branch's PR has been squash-merged, the rebase automatically switches to `--onto` mode to correctly replay commits on top of the merge target.
226+
If a branch's PR has been merged, the rebase automatically switches to `--onto` mode to correctly replay commits on top of the merge target.
227227

228228
If a rebase conflict occurs, the operation pauses and prints the conflicted files with line numbers. Resolve the conflicts, stage with `git add`, and continue with `--continue`. To undo the entire rebase, use `--abort` to restore all branches to their pre-rebase state.
229229

internal/git/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func SaveRerereDeclined() error {
179179
// git rebase --onto <newBase> <oldBase> <branch>
180180
//
181181
// This replays commits after oldBase from branch onto newBase. It is used
182-
// when a prior branch was squash-merged and the normal rebase cannot detect
182+
// when a prior branch was merged and the normal rebase cannot detect
183183
// which commits have already been applied.
184184
// If rerere resolves all conflicts automatically, the rebase continues
185185
// without user intervention.

skills/gh-stack/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ gh stack sync [flags]
570570

571571
1. **Fetch** latest changes from the remote
572572
2. **Fast-forward trunk** to match remote (skips if already up to date, warns if diverged)
573-
3. **Cascade rebase** all stack branches onto their updated parents (only if trunk moved). Handles squash-merged PRs automatically. If a conflict is detected, **all branches are restored** to their pre-rebase state and the command exits with code 3 — see [Handle rebase conflicts](#handle-rebase-conflicts-agent-workflow) for the resolution workflow
573+
3. **Cascade rebase** all stack branches onto their updated parents (only if trunk moved). Handles merged PRs automatically. If a conflict is detected, **all branches are restored** to their pre-rebase state and the command exits with code 3 — see [Handle rebase conflicts](#handle-rebase-conflicts-agent-workflow) for the resolution workflow
574574
4. **Push** all active branches atomically
575575
5. **Sync PR state** from GitHub and report the status of each PR
576576

@@ -625,7 +625,7 @@ gh stack rebase --abort
625625

626626
**Conflict handling:** See [Handle rebase conflicts](#handle-rebase-conflicts-agent-workflow) in the Workflows section for the full resolution workflow.
627627

628-
**Squash-merge detection:** If a branch's PR was squash-merged on GitHub, the rebase automatically handles this and correctly replays commits on top of the merge target.
628+
**Merged PR detection:** If a branch's PR was merged on GitHub, the rebase automatically handles this using `--onto` mode and correctly replays commits on top of the merge target.
629629

630630
**Rerere (conflict memory):** `git rerere` is enabled by `init` so previously resolved conflicts are auto-resolved in future rebases.
631631

0 commit comments

Comments
 (0)