@@ -1269,6 +1269,88 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
12691269 } ) ,
12701270 ) ;
12711271
1272+ it . effect . each ( [
1273+ { action : "worktree add" , detail : "git worktree add failed" } ,
1274+ { action : "switch" , detail : "git checkout failed" } ,
1275+ ] ) (
1276+ "reports a missing ref during $action with stable, redacted diagnostics" ,
1277+ ( { action, detail } ) =>
1278+ Effect . gen ( function * ( ) {
1279+ const cwd = yield * makeTmpDir ( ) ;
1280+ yield * initRepoWithCommit ( cwd ) ;
1281+ const path = yield * Path . Path ;
1282+ const refName = "private/deleted-base" ;
1283+ const locales : Array < string | undefined > = [ ] ;
1284+ const delegate = yield * ChildProcessSpawner . ChildProcessSpawner ;
1285+ const spawner = ChildProcessSpawner . make ( ( command ) => {
1286+ if (
1287+ ChildProcess . isStandardCommand ( command ) &&
1288+ ( command . args . includes ( "worktree" ) || command . args [ 0 ] === "checkout" )
1289+ ) {
1290+ locales . push ( command . options . env ?. LC_ALL ) ;
1291+ }
1292+ return delegate . spawn ( command ) ;
1293+ } ) ;
1294+ const driver = yield * makeGitVcsDriverCore ( ) . pipe (
1295+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , spawner ) ,
1296+ Effect . provide ( layerServerConfig ) ,
1297+ ) ;
1298+ const error =
1299+ action === "switch"
1300+ ? yield * driver . switchRef ( { cwd, refName } ) . pipe ( Effect . flip )
1301+ : yield * driver
1302+ . createWorktree ( {
1303+ cwd,
1304+ refName,
1305+ newRefName : "t3/new-thread" ,
1306+ path : path . join ( cwd , "worktree" ) ,
1307+ } )
1308+ . pipe ( Effect . flip ) ;
1309+
1310+ assert . deepInclude ( error , { _tag : "GitCommandError" , detail, reason : "ref_not_found" } ) ;
1311+ assert . include ( error . message , `${ detail } (ref_not_found)` ) ;
1312+ assert . notInclude ( error . message , refName ) ;
1313+ assert . notInclude ( yield * encodeGitCommandError ( error ) , refName ) ;
1314+ assert . deepEqual ( locales , [ "C" ] ) ;
1315+ assert . notProperty ( error , "stderr" ) ;
1316+ assert . notProperty ( error , "args" ) ;
1317+ } ) ,
1318+ ) ;
1319+
1320+ it . effect . each ( [
1321+ // Git cannot tell a missing revision from a missing file in these.
1322+ { label : "an argument that may be a path" , args : [ "log" , "-1" , "missing" ] } ,
1323+ {
1324+ label : "a pathspec worded like a diagnostic" ,
1325+ args : [ "checkout" , "HEAD" , "--" , "fatal: invalid reference: missing" ] ,
1326+ } ,
1327+ // The tag exists; it names a tree, which git reports in the same words.
1328+ {
1329+ label : "a worktree from a non-commit" ,
1330+ args : [ "worktree" , "add" , "tree-worktree" , "tree-tag" ] ,
1331+ } ,
1332+ ] ) ( "leaves $label unclassified rather than calling it a missing ref" , ( { args } ) =>
1333+ Effect . gen ( function * ( ) {
1334+ const cwd = yield * makeTmpDir ( ) ;
1335+ const driver = yield * GitVcsDriver . GitVcsDriver ;
1336+ yield * initRepoWithCommit ( cwd ) ;
1337+ if ( args . includes ( "tree-tag" ) ) {
1338+ yield * git ( cwd , [ "tag" , "tree-tag" , "HEAD^{tree}" ] ) ;
1339+ }
1340+
1341+ const error = yield * driver
1342+ . execute ( {
1343+ operation : "GitVcsDriver.test.ambiguousMissingName" ,
1344+ cwd,
1345+ args,
1346+ env : { LC_ALL : "C" } ,
1347+ } )
1348+ . pipe ( Effect . flip ) ;
1349+
1350+ assert . notProperty ( error , "reason" ) ;
1351+ } ) ,
1352+ ) ;
1353+
12721354 it . effect . each ( [
12731355 {
12741356 label : "a refused key" ,
0 commit comments