@@ -1277,6 +1277,47 @@ it.effect("GitVcsDriver forwards execute env to the VCS process", () => {
12771277 ) ;
12781278} ) ;
12791279
1280+ // The real VCS process, spawning `command` wherever the driver runs git.
1281+ const vcsProcessSpawning = ( command : string ) =>
1282+ Layer . effect (
1283+ VcsProcess . VcsProcess ,
1284+ Effect . map ( VcsProcess . make , ( vcsProcess ) =>
1285+ VcsProcess . VcsProcess . of ( { run : ( input ) => vcsProcess . run ( { ...input , command } ) } ) ,
1286+ ) ,
1287+ ) . pipe ( Layer . provide ( ProcessRunner . layer ) , Layer . provideMerge ( NodeServices . layer ) ) ;
1288+
1289+ it . effect ( "GitVcsDriver treats a missing git executable as outside any repository" , ( ) =>
1290+ Effect . gen ( function * ( ) {
1291+ const fileSystem = yield * FileSystem . FileSystem ;
1292+ const path = yield * Path . Path ;
1293+ const cwd = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "t3-missing-git-" } ) ;
1294+ const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) . pipe (
1295+ Effect . provide ( vcsProcessSpawning ( path . join ( cwd , "git" ) ) ) ,
1296+ ) ;
1297+
1298+ assert . strictEqual ( yield * driver . isInsideWorkTree ( cwd ) , false ) ;
1299+ assert . strictEqual ( yield * driver . detectRepository ( cwd ) , null ) ;
1300+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
1301+ ) ;
1302+
1303+ it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) === "win32" ) (
1304+ "GitVcsDriver still fails detection when git exists but cannot be spawned" ,
1305+ ( ) =>
1306+ Effect . gen ( function * ( ) {
1307+ const fileSystem = yield * FileSystem . FileSystem ;
1308+ // A file without the execute bit fails to spawn with a permission error.
1309+ const notExecutable = yield * fileSystem . makeTempFileScoped ( { prefix : "t3-git-" } ) ;
1310+ const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) . pipe (
1311+ Effect . provide ( vcsProcessSpawning ( notExecutable ) ) ,
1312+ ) ;
1313+
1314+ const error = yield * driver . isInsideWorkTree ( process . cwd ( ) ) . pipe ( Effect . flip ) ;
1315+ assert . strictEqual ( error . _tag , "VcsProcessSpawnError" ) ;
1316+ const detectionError = yield * driver . detectRepository ( process . cwd ( ) ) . pipe ( Effect . flip ) ;
1317+ assert . strictEqual ( detectionError . _tag , "VcsProcessSpawnError" ) ;
1318+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
1319+ ) ;
1320+
12801321it . effect ( "GitVcsDriver flushes checkpoint objects and refs to disk before publishing them" , ( ) => {
12811322 const observedArgs : ReadonlyArray < string > [ ] = [ ] ;
12821323
0 commit comments