@@ -92,4 +92,49 @@ describe("VcsDriverRegistry", () => {
9292 ) ;
9393 } ) . pipe ( Effect . provide ( layer ) ) ;
9494 } ) ;
95+
96+ it . effect ( "detects a repository created after a negative lookup" , ( ) => {
97+ let insideWorkTreeChecks = 0 ;
98+ const layer = Layer . effect ( VcsDriverRegistry . VcsDriverRegistry , VcsDriverRegistry . make ) . pipe (
99+ Layer . provide ( NodeServices . layer ) ,
100+ Layer . provide (
101+ Layer . mock ( VcsProjectConfig . VcsProjectConfig ) ( {
102+ resolveKind : ( input ) => Effect . succeed ( input . requestedKind ?? "auto" ) ,
103+ } ) ,
104+ ) ,
105+ Layer . provide (
106+ Layer . mock ( VcsProcess . VcsProcess ) ( {
107+ run : ( input ) =>
108+ Effect . sync ( ( ) => {
109+ const command = normalizeGitArgs ( input . args ) . join ( " " ) ;
110+ if ( command === "rev-parse --is-inside-work-tree" ) {
111+ insideWorkTreeChecks += 1 ;
112+ return insideWorkTreeChecks === 1
113+ ? {
114+ ...processOutput ( "" ) ,
115+ exitCode : ChildProcessSpawner . ExitCode ( 128 ) ,
116+ stderr : "fatal: not a git repository" ,
117+ }
118+ : processOutput ( "true\n" ) ;
119+ }
120+ if ( command === "rev-parse --show-toplevel" ) {
121+ return processOutput ( "/repo\n" ) ;
122+ }
123+ if ( command === "rev-parse --git-common-dir" ) {
124+ return processOutput ( "/repo/.git\n" ) ;
125+ }
126+ return processOutput ( "" ) ;
127+ } ) ,
128+ } ) ,
129+ ) ,
130+ ) ;
131+
132+ return Effect . gen ( function * ( ) {
133+ const registry = yield * VcsDriverRegistry . VcsDriverRegistry ;
134+
135+ assert . equal ( yield * registry . detect ( { cwd : "/repo" } ) , null ) ;
136+ assert . equal ( ( yield * registry . detect ( { cwd : "/repo" } ) ) ?. repository . rootPath , "/repo" ) ;
137+ assert . equal ( insideWorkTreeChecks , 2 ) ;
138+ } ) . pipe ( Effect . provide ( layer ) ) ;
139+ } ) ;
95140} ) ;
0 commit comments