@@ -15,10 +15,11 @@ import (
1515
1616// mockRunner records calls without executing git.
1717type mockRunner struct {
18- clones []string
19- fetches []string
20- worktrees []string
21- removed []string
18+ clones []string
19+ fetches []string
20+ worktrees []string
21+ removed []string
22+ startPoints []string
2223
2324 cloneErr error
2425 fetchErr error
@@ -47,7 +48,8 @@ func (m *mockRunner) AddWorktree(_ context.Context, _, worktreePath, _ string) e
4748 return os .MkdirAll (worktreePath , 0o755 )
4849}
4950
50- func (m * mockRunner ) AddWorktreeNewBranch (_ context.Context , _ , worktreePath , _ , _ string ) error {
51+ func (m * mockRunner ) AddWorktreeNewBranch (_ context.Context , _ , worktreePath , _ , startPoint string ) error {
52+ m .startPoints = append (m .startPoints , startPoint )
5153 m .worktrees = append (m .worktrees , worktreePath )
5254 if m .addWTErr != nil {
5355 return m .addWTErr
@@ -415,6 +417,32 @@ func TestRenderAddWorktreeError(t *testing.T) {
415417 }
416418}
417419
420+ func TestRenderNewBranchUsesRemoteRef (t * testing.T ) {
421+ svc , mock := testService (t )
422+ ctx := context .Background ()
423+
424+ st := state .NewState ("Remote ref test" , "Test new branch uses origin/ prefix" , []state.Repo {
425+ {URL : "github.com/org/repo" , Branch : "feat/new-feature" , Path : "./repo" },
426+ })
427+ if err := svc .Create ("remote-ref" , st ); err != nil {
428+ t .Fatal (err )
429+ }
430+
431+ // branchExists=false triggers the new branch path
432+ mock .branchExists = false
433+ err := svc .Render (ctx , "remote-ref" , noop )
434+ if err != nil {
435+ t .Fatalf ("Render: %v" , err )
436+ }
437+
438+ if len (mock .startPoints ) != 1 {
439+ t .Fatalf ("startPoints = %d, want 1" , len (mock .startPoints ))
440+ }
441+ if mock .startPoints [0 ] != "origin/main" {
442+ t .Errorf ("startPoint = %q, want origin/main" , mock .startPoints [0 ])
443+ }
444+ }
445+
418446func TestRenderNotFound (t * testing.T ) {
419447 svc , _ := testService (t )
420448 ctx := context .Background ()
0 commit comments