remove silent prefix detection in init#126
Open
skarim wants to merge 2 commits into
Open
Conversation
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.
Contributor
There was a problem hiding this comment.
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
detectPrefixcall block from the args path, so explicit branch names are taken literally - Update two test cases (
ArgsCommonPrefixandNestedPrefix) 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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When explicit branch names containing slashes were passed to
gh stack init(e.g.gh stack init myprefix/branch),detectPrefixwas silently extracting the prefix and storing it in the stack config. This causedgh stack add otherbranchto unexpectedly producemyprefix/otherbranchwithout 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 silentdetectPrefixblock from the args path — explicit branch names are taken literally. Users who want a prefix should use--prefix.cmd/init_test.go: updateArgsCommonPrefixandNestedPrefixtests to expect no prefix detection from explicit argsStack created with GitHub Stacks CLI • Give Feedback 💬