@@ -5,6 +5,7 @@ import { expect, it } from "@effect/vitest";
55import * as Effect from "effect/Effect" ;
66import * as FileSystem from "effect/FileSystem" ;
77import * as Path from "effect/Path" ;
8+ import { vi } from "vite-plus/test" ;
89
910import * as ProcessRunner from "../processRunner.ts" ;
1011import * as RepositoryIdentityResolver from "./RepositoryIdentityResolver.ts" ;
@@ -343,6 +344,35 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
343344 } ) . pipe ( Effect . provide ( RepositoryIdentityResolver . layer ) ) ,
344345 ) ;
345346
347+ it . effect ( "reads the project's gh default when the server inherited GIT_DIR" , ( ) =>
348+ Effect . gen ( function * ( ) {
349+ const fileSystem = yield * FileSystem . FileSystem ;
350+ const path = yield * Path . Path ;
351+ const cwd = yield * fileSystem . makeTempDirectoryScoped ( {
352+ prefix : "t3-repository-identity-gh-default-git-dir-" ,
353+ } ) ;
354+ const other = yield * fileSystem . makeTempDirectoryScoped ( {
355+ prefix : "t3-repository-identity-inherited-git-dir-" ,
356+ } ) ;
357+
358+ yield * git ( cwd , [ "init" ] ) ;
359+ yield * git ( cwd , [ "remote" , "add" , "origin" , "[email protected] :julius/t3code-fork.git" ] ) ; 360+ yield * git ( cwd , [ "remote" , "add" , "upstream" , "[email protected] :T3Tools/t3code.git" ] ) ; 361+ yield * git ( cwd , [ "config" , "remote.origin.gh-resolved" , "base" ] ) ;
362+ yield * git ( other , [ "init" ] ) ;
363+ yield * git ( other , [ "config" , "remote.upstream.gh-resolved" , "base" ] ) ;
364+
365+ vi . stubEnv ( "GIT_DIR" , path . join ( other , ".git" ) ) ;
366+ yield * Effect . addFinalizer ( ( ) => Effect . sync ( ( ) => vi . unstubAllEnvs ( ) ) ) ;
367+
368+ const resolver = yield * RepositoryIdentityResolver . RepositoryIdentityResolver ;
369+ const identity = yield * resolver . resolve ( cwd ) ;
370+
371+ expect ( identity ?. canonicalKey ) . toBe ( "github.com/julius/t3code-fork" ) ;
372+ expect ( identity ?. locator . remoteName ) . toBe ( "origin" ) ;
373+ } ) . pipe ( Effect . provide ( RepositoryIdentityResolver . layer ) ) ,
374+ ) ;
375+
346376 it . effect ( "uses the last remote path segment as the repository name for nested groups" , ( ) =>
347377 Effect . gen ( function * ( ) {
348378 const fileSystem = yield * FileSystem . FileSystem ;
0 commit comments