Skip to content

remove silent prefix detection in init#126

Open
skarim wants to merge 2 commits into
skarim/fix-no-local-trunkfrom
skarim/init-rm-silent-add-prefix
Open

remove silent prefix detection in init#126
skarim wants to merge 2 commits into
skarim/fix-no-local-trunkfrom
skarim/init-rm-silent-add-prefix

Conversation

@skarim

@skarim skarim commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

When explicit branch names containing slashes were passed to gh stack init (e.g. gh stack init myprefix/branch), detectPrefix was silently extracting the prefix and storing it in the stack config. This caused gh stack add otherbranch to unexpectedly produce myprefix/otherbranch without the user ever opting in.

The interactive path correctly prompts for confirmation ("Use myprefix/ as a prefix?"), but the args path had no such guard.

Changes

  • cmd/init.go: remove the silent detectPrefix block from the args path — explicit branch names are taken literally. Users who want a prefix should use --prefix.
  • cmd/init_test.go: update ArgsCommonPrefix and NestedPrefix tests to expect no prefix detection from explicit args

Stack created with GitHub Stacks CLIGive Feedback 💬

When explicit branch names containing slashes were passed to `gh stack
init` (e.g. `gh stack init myprefix/branch`), detectPrefix would
silently extract the prefix and store it in the stack config. This
caused `gh stack add otherbranch` to unexpectedly produce
`myprefix/otherbranch` without the user ever opting in.

Remove the automatic prefix detection from the args path so that
explicit branch names are taken literally. Users who want a prefix
should use `--prefix`. The interactive path (no args) continues to
prompt for confirmation before setting a prefix.
@skarim skarim marked this pull request as ready for review June 15, 2026 03:45
Copilot AI review requested due to automatic review settings June 15, 2026 03:45

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

This PR removes the silent prefix auto-detection behavior from the explicit args path in gh stack init. Previously, when users passed branch names containing slashes (e.g., gh stack init feat/a feat/b), the detectPrefix function would silently extract "feat" as a prefix and store it in the stack config. This caused unexpected behavior when adding new branches later (e.g., gh stack add otherbranch producing feat/otherbranch without user consent). The interactive path already properly prompts for confirmation.

Changes:

  • Remove the 6-line detectPrefix call block from the args path, so explicit branch names are taken literally
  • Update two test cases (ArgsCommonPrefix and NestedPrefix) to assert empty prefix, reflecting the new behavior
Show a summary per file
File Description
cmd/init.go Removes the silent detectPrefix invocation from the args path
cmd/init_test.go Updates test assertions to expect no prefix detection from explicit args; updates test comments to explain the rationale

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread cmd/init.go
After removing the silent prefix detection from the args path,
detectPrefix has no production callers. Remove the function and
its table-driven unit test to avoid maintaining unused code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
GitHub Advanced Security started work on behalf of skarim June 15, 2026 04:03 View session
GitHub Advanced Security finished work on behalf of skarim June 15, 2026 04:04
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.

3 participants