Skip to content

Commit 1ad3e87

Browse files
committed
update add error msg to direct users to modify for inserting branches
1 parent 8d3ae85 commit 1ad3e87

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

cmd/add.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ func runAdd(cfg *config.Config, opts *addOptions, args []string) error {
8585
// idx < 0 means we're on the trunk — that's allowed (we'll create
8686
// a new branch from it). Only block if we're in the middle of the stack.
8787
if idx >= 0 && idx < len(s.Branches)-1 {
88-
cfg.Errorf("can only add branches on top of the stack; run `%s` to switch to %q", cfg.ColorCyan("gh stack top"), s.Branches[len(s.Branches)-1].Branch)
88+
cfg.Errorf("can only add branches to the top of the stack; run `%s` then `%s`", cfg.ColorCyan("gh stack top"), cfg.ColorCyan("gh stack add"))
89+
cfg.Printf("Or to restructure your stack and insert a branch, use `%s`", cfg.ColorCyan("gh stack modify"))
8990
return ErrInvalidArgs
9091
}
9192

cmd/add_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func TestAdd_OnlyAllowedOnTopOfStack(t *testing.T) {
7878
output := collectOutput(cfg, outR, errR)
7979

8080
assert.Contains(t, output, "top of the stack")
81+
assert.Contains(t, output, "gh stack modify")
8182
}
8283

8384
func TestAdd_MutuallyExclusiveFlags(t *testing.T) {

0 commit comments

Comments
 (0)