Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ func runInit(cfg *config.Config, opts *initOptions) error {
return err
}

Comment thread
skarim marked this conversation as resolved.
// Prefix detection (only when --prefix not explicitly set)
if opts.prefix == "" {
if detected := detectPrefix(branches); detected != "" {
opts.prefix = detected
}
}

} else if opts.numbered {
// === NUMBERED PATH (unchanged) ===
if opts.prefix == "" && cfg.IsInteractive() {
Expand Down
11 changes: 7 additions & 4 deletions cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ func TestInit_ImplicitAdopt_Mixed(t *testing.T) {
}

func TestInit_PrefixDetection_ArgsCommonPrefix(t *testing.T) {
// Scenario 9: args all share prefix → set silently
// Explicit branch names with a common prefix should NOT auto-detect
// a prefix — the slash is part of the branch name, not a convention.
// Users who want a prefix should use --prefix.
gitDir := t.TempDir()
restore := git.SetOps(&git.MockOps{
GitDirFn: func() (string, error) { return gitDir, nil },
Expand All @@ -481,7 +483,7 @@ func TestInit_PrefixDetection_ArgsCommonPrefix(t *testing.T) {

require.NoError(t, err)
sf, _ := stack.Load(gitDir)
assert.Equal(t, "feat", sf.Stacks[0].Prefix)
assert.Equal(t, "", sf.Stacks[0].Prefix)
}

func TestInit_PrefixDetection_ArgsMixedPrefix(t *testing.T) {
Expand Down Expand Up @@ -525,7 +527,8 @@ func TestInit_PrefixDetection_ArgsNoSlash(t *testing.T) {
}

func TestInit_PrefixDetection_NestedPrefix(t *testing.T) {
// Scenario 6: sameen/feat/x → prefix "sameen/feat"
// Explicit branch names with nested slashes should NOT auto-detect
// a prefix — the user typed the full branch name deliberately.
gitDir := t.TempDir()
restore := git.SetOps(&git.MockOps{
GitDirFn: func() (string, error) { return gitDir, nil },
Expand All @@ -541,7 +544,7 @@ func TestInit_PrefixDetection_NestedPrefix(t *testing.T) {

require.NoError(t, err)
sf, _ := stack.Load(gitDir)
assert.Equal(t, "sameen/feat", sf.Stacks[0].Prefix)
assert.Equal(t, "", sf.Stacks[0].Prefix)
}

func TestInit_ExplicitPrefixSkipsDetection(t *testing.T) {
Expand Down