@@ -155,6 +155,67 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
155155 } ) ,
156156 ) ;
157157
158+ it . effect ( "reports remote divergence without reading working-tree details" , ( ) =>
159+ Effect . gen ( function * ( ) {
160+ const cwd = yield * makeTmpDir ( ) ;
161+ const remote = yield * makeTmpDir ( "git-vcs-driver-remote-" ) ;
162+ const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
163+ yield * git ( remote , [ "init" , "--bare" ] ) ;
164+ yield * git ( cwd , [ "remote" , "add" , "origin" , remote ] ) ;
165+ yield * git ( cwd , [ "push" , "-u" , "origin" , initialBranch ] ) ;
166+ yield * git ( cwd , [ "checkout" , "-b" , "feature/remote-status" ] ) ;
167+ yield * writeTextFile ( cwd , "feature.txt" , "feature\n" ) ;
168+ yield * git ( cwd , [ "add" , "feature.txt" ] ) ;
169+ yield * git ( cwd , [ "commit" , "-m" , "feature commit" ] ) ;
170+ yield * git ( cwd , [ "push" , "-u" , "origin" , "feature/remote-status" ] ) ;
171+ yield * writeTextFile ( cwd , "untracked.txt" , "local-only\n" ) ;
172+
173+ const status = yield * ( yield * GitVcsDriver . GitVcsDriver ) . statusDetailsRemote ( cwd ) ;
174+
175+ assert . equal ( status . isRepo , true ) ;
176+ assert . equal ( status . branch , "feature/remote-status" ) ;
177+ assert . equal ( status . hasUpstream , true ) ;
178+ assert . equal ( status . aheadCount , 0 ) ;
179+ assert . equal ( status . behindCount , 0 ) ;
180+ assert . equal ( status . aheadOfDefaultCount , 1 ) ;
181+ assert . notProperty ( status , "workingTree" ) ;
182+ assert . notProperty ( status , "hasWorkingTreeChanges" ) ;
183+ } ) ,
184+ ) ;
185+
186+ it . effect ( "uses origin HEAD for default-branch detection with a non-origin upstream" , ( ) =>
187+ Effect . gen ( function * ( ) {
188+ const cwd = yield * makeTmpDir ( ) ;
189+ const origin = yield * makeTmpDir ( "git-vcs-driver-origin-" ) ;
190+ const upstream = yield * makeTmpDir ( "git-vcs-driver-upstream-" ) ;
191+ yield * initRepoWithCommit ( cwd ) ;
192+ yield * git ( origin , [ "init" , "--bare" ] ) ;
193+ yield * git ( upstream , [ "init" , "--bare" ] ) ;
194+ yield * git ( cwd , [ "branch" , "-M" , "main" ] ) ;
195+ yield * git ( cwd , [ "remote" , "add" , "origin" , origin ] ) ;
196+ yield * git ( cwd , [ "remote" , "add" , "upstream" , upstream ] ) ;
197+ yield * git ( cwd , [ "push" , "origin" , "main" ] ) ;
198+ yield * git ( cwd , [ "push" , "upstream" , "main" ] ) ;
199+ yield * git ( cwd , [ "symbolic-ref" , "refs/remotes/origin/HEAD" , "refs/remotes/origin/main" ] ) ;
200+ yield * git ( cwd , [ "checkout" , "-b" , "release" ] ) ;
201+ yield * writeTextFile ( cwd , "release.txt" , "release\n" ) ;
202+ yield * git ( cwd , [ "add" , "release.txt" ] ) ;
203+ yield * git ( cwd , [ "commit" , "-m" , "release commit" ] ) ;
204+ yield * git ( cwd , [ "push" , "-u" , "upstream" , "release" ] ) ;
205+ yield * git ( cwd , [
206+ "symbolic-ref" ,
207+ "refs/remotes/upstream/HEAD" ,
208+ "refs/remotes/upstream/release" ,
209+ ] ) ;
210+
211+ const status = yield * ( yield * GitVcsDriver . GitVcsDriver ) . statusDetailsRemote ( cwd ) ;
212+
213+ assert . equal ( status . branch , "release" ) ;
214+ assert . equal ( status . upstreamRef , "upstream/release" ) ;
215+ assert . equal ( status . isDefaultBranch , false ) ;
216+ } ) ,
217+ ) ;
218+
158219 it . effect ( "disables SSH askpass for background upstream status fetches" , ( ) =>
159220 Effect . gen ( function * ( ) {
160221 const cwd = yield * makeTmpDir ( ) ;
0 commit comments