Skip to content

add: offer to initialize a stack automatically - #486

Merged
skarim merged 3 commits into
mainfrom
skarim/add-auto-init
Aug 27, 2026
Merged

add: offer to initialize a stack automatically#486
skarim merged 3 commits into
mainfrom
skarim/add-auto-init

Conversation

@skarim

@skarim skarim commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

When gh stack add runs from a branch that is not part of a stack, it now offers to initialize a new stack instead of failing. Explicit and auto-generated branch names become the first layer; without a name, the existing init flow handles branch selection and prompting.

The shortcut reuses runInit, preserves commit flags, and leaves declined confirmations and non-interactive behavior unchanged. init now also restores a missing local trunk from the selected remote before branch creation, covering repositories where the default branch was renamed locally.

README and CLI reference documentation are updated along with regression coverage for both flows.

Copilot AI balanced review requested due to automatic review settings August 27, 2026 05:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an interactive fallback that initializes a stack when gh stack add runs outside one.

Changes:

  • Reuses runInit from add, preserving branch and commit options.
  • Restores missing local trunk branches from remotes.
  • Updates documentation and regression tests.
Show a summary per file
File Description
README.md Documents automatic initialization flow.
docs/src/content/docs/reference/cli.md Updates CLI reference.
cmd/utils.go Adds optional stack lookup.
cmd/init.go Restores missing local trunks.
cmd/init_test.go Tests trunk restoration.
cmd/add.go Adds initialization prompt and flow.
cmd/add_test.go Tests initialization scenarios.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread cmd/init.go Outdated
@skarim
skarim merged commit 3765b9b into main Aug 27, 2026
7 checks passed
@skarim
skarim deleted the skarim/add-auto-init branch August 27, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow gh stack add to initialize a stack when current branch is not part of a stack

3 participants