@@ -166,38 +166,22 @@ func TestInit_InvalidPrefixRejectedBeforeBranchCreation(t *testing.T) {
166166 assert .Empty (t , created , "no branches should be created when prefix is invalid" )
167167}
168168
169- func TestInit_AdoptRejectsPrefix (t * testing.T ) {
170- gitDir := t .TempDir ()
171- restore := git .SetOps (& git.MockOps {
172- GitDirFn : func () (string , error ) { return gitDir , nil },
173- DefaultBranchFn : func () (string , error ) { return "main" , nil },
174- CurrentBranchFn : func () (string , error ) { return "main" , nil },
175- })
176- defer restore ()
177-
178- cfg , outR , errR := config .NewTestConfig ()
179- err := runInit (cfg , & initOptions {adopt : true , branches : []string {"b1" }, prefix : "feat" })
180- output := collectOutput (cfg , outR , errR )
181-
182- assert .ErrorIs (t , err , ErrInvalidArgs )
183- assert .Contains (t , output , "--adopt cannot be combined with --prefix or --numbered" )
184- }
185-
186- func TestInit_AdoptRejectsNumbered (t * testing.T ) {
169+ func TestInit_AdoptFlagShowsDeprecationWarning (t * testing.T ) {
187170 gitDir := t .TempDir ()
188171 restore := git .SetOps (& git.MockOps {
189172 GitDirFn : func () (string , error ) { return gitDir , nil },
190173 DefaultBranchFn : func () (string , error ) { return "main" , nil },
191174 CurrentBranchFn : func () (string , error ) { return "main" , nil },
175+ BranchExistsFn : func (string ) bool { return true },
192176 })
193177 defer restore ()
194178
195179 cfg , outR , errR := config .NewTestConfig ()
196- err := runInit (cfg , & initOptions {adopt : true , branches : []string {"b1" }, numbered : true })
180+ err := runInit (cfg , & initOptions {adopt : true , branches : []string {"b1" }})
197181 output := collectOutput (cfg , outR , errR )
198182
199- assert . ErrorIs (t , err , ErrInvalidArgs )
200- assert .Contains (t , output , "--adopt cannot be combined with --prefix or --numbered " )
183+ require . NoError (t , err )
184+ assert .Contains (t , output , "--adopt flag is deprecated " )
201185}
202186
203187func TestInit_RerereAlreadyEnabled (t * testing.T ) {
@@ -249,21 +233,29 @@ func TestInit_RefuseIfBranchAlreadyInStack(t *testing.T) {
249233 assert .Contains (t , output , "already part of a stack" )
250234}
251235
252- func TestInit_AdoptNonexistentBranch (t * testing.T ) {
236+ func TestInit_AdoptNonexistentBranch_CreatesIt (t * testing.T ) {
237+ // --adopt with missing branch now creates it (no error, just a deprecation warning)
253238 gitDir := t .TempDir ()
239+ var created []string
254240 restore := git .SetOps (& git.MockOps {
255241 GitDirFn : func () (string , error ) { return gitDir , nil },
256242 DefaultBranchFn : func () (string , error ) { return "main" , nil },
257243 CurrentBranchFn : func () (string , error ) { return "main" , nil },
258244 BranchExistsFn : func (string ) bool { return false },
245+ CreateBranchFn : func (name , base string ) error {
246+ created = append (created , name )
247+ return nil
248+ },
259249 })
260250 defer restore ()
261251
262252 cfg , outR , errR := config .NewTestConfig ()
263- runInit (cfg , & initOptions {branches : []string {"nonexistent" }, adopt : true })
253+ err := runInit (cfg , & initOptions {branches : []string {"nonexistent" }, adopt : true })
264254 output := collectOutput (cfg , outR , errR )
265255
266- assert .Contains (t , output , "does not exist" )
256+ require .NoError (t , err )
257+ assert .Contains (t , output , "--adopt flag is deprecated" )
258+ assert .Equal (t , []string {"nonexistent" }, created )
267259}
268260
269261func TestInit_MultipleBranches_CreatesAll (t * testing.T ) {
@@ -472,25 +464,6 @@ func TestInit_ImplicitAdopt_Mixed(t *testing.T) {
472464 assert .Equal (t , []string {"existing1" , "new1" , "existing2" }, sf .Stacks [0 ].BranchNames ())
473465}
474466
475- func TestInit_StrictAdopt_MissingBranch (t * testing.T ) {
476- // Scenario 13: --adopt with missing branch → error
477- gitDir := t .TempDir ()
478- restore := git .SetOps (& git.MockOps {
479- GitDirFn : func () (string , error ) { return gitDir , nil },
480- DefaultBranchFn : func () (string , error ) { return "main" , nil },
481- CurrentBranchFn : func () (string , error ) { return "main" , nil },
482- BranchExistsFn : func (name string ) bool { return name == "b1" },
483- })
484- defer restore ()
485-
486- cfg , outR , errR := config .NewTestConfig ()
487- err := runInit (cfg , & initOptions {branches : []string {"b1" , "b2-missing" }, adopt : true })
488- output := collectOutput (cfg , outR , errR )
489-
490- assert .ErrorIs (t , err , ErrInvalidArgs )
491- assert .Contains (t , output , "does not exist" )
492- }
493-
494467func TestInit_PrefixDetection_ArgsCommonPrefix (t * testing.T ) {
495468 // Scenario 9: args all share prefix → set silently
496469 gitDir := t .TempDir ()
0 commit comments