Skip to content

Commit f0ec7d5

Browse files
committed
more helpful error msgs
1 parent 028a576 commit f0ec7d5

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

cmd/merge.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@ func resolveActiveRemoteStack(cfg *config.Config, client github.ClientOps) (*git
237237
stacks := sf.FindAllStacksForBranch(currentBranch)
238238
if len(stacks) == 0 {
239239
cfg.Errorf("current branch %q is not part of a stack", currentBranch)
240+
cfg.Printf("Checkout a stack first, or specify which stack or pull request to merge with `%s`", cfg.ColorCyan("gh stack merge [number]"))
240241
return nil, ErrNotInStack
241242
}
242243
if len(stacks) > 1 {
243-
cfg.Errorf("branch %q belongs to multiple stacks; check out a non-trunk branch first", currentBranch)
244+
cfg.Errorf("branch %q belongs to multiple stacks", currentBranch)
245+
cfg.Printf("Checkout a stack first, or specify which stack or pull request to merge with `%s`", cfg.ColorCyan("gh stack merge [number]"))
244246
return nil, ErrDisambiguate
245247
}
246248
s := stacks[0]

cmd/merge_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ func TestRunMerge_NoArg_NotInStack(t *testing.T) {
413413

414414
assert.ErrorIs(t, err, ErrNotInStack)
415415
assert.Contains(t, output, "not part of a stack")
416+
assert.Contains(t, output, "Checkout a stack first, or specify which stack or pull request to merge with")
417+
assert.Contains(t, output, "gh stack merge [number]")
416418
}
417419

418420
func TestRunMerge_DefaultMethodFallsBackToAllowed(t *testing.T) {

0 commit comments

Comments
 (0)