Skip to content

Commit a13268d

Browse files
javoireclaude
andauthored
fix: don't suggest stacking base branch onto itself (#51)
When running `stack status` on the base branch (e.g., main), the command would incorrectly offer to add it to a stack with itself as parent. Accepting this created a circular dependency (main → main). Now detects when the current branch is the base branch and shows a helpful message instead of the problematic prompt. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e434572 commit a13268d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

cmd/status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ func runStatus(gitClient git.GitClient, githubClient github.GitHubClient) error
143143
// Check this BEFORE waiting for PR fetch to avoid long delays
144144
if tree == nil {
145145
baseBranch := stack.GetBaseBranch(gitClient)
146+
147+
// Don't offer to add the base branch to a stack - it can't have a parent
148+
if currentBranch == baseBranch {
149+
fmt.Printf("Branch '%s' is the base branch and cannot be part of a stack.\n", ui.Branch(currentBranch))
150+
fmt.Printf("\nUse '%s' to create a new stack branch.\n", ui.Command("stack new <branch-name>"))
151+
return nil
152+
}
153+
146154
fmt.Printf("Current branch '%s' is not part of a stack.\n\n", ui.Branch(currentBranch))
147155
fmt.Printf("Add to stack with '%s' as parent? [Y/n] ", ui.Branch(baseBranch))
148156

0 commit comments

Comments
 (0)