@@ -1269,88 +1269,74 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
12691269 } ) ,
12701270 ) ;
12711271
1272- it . effect ( "names the missing base ref behind a failed worktree add" , ( ) =>
1273- Effect . gen ( function * ( ) {
1274- const parent = yield * makeTmpDir ( ) ;
1275- const pathService = yield * Path . Path ;
1276- const cwd = pathService . join ( parent , "repo" ) ;
1277- const fileSystem = yield * FileSystem . FileSystem ;
1278- yield * fileSystem . makeDirectory ( cwd ) ;
1279- const driver = yield * GitVcsDriver . GitVcsDriver ;
1280- yield * initRepoWithCommit ( cwd ) ;
1281-
1282- const error = yield * driver
1283- . createWorktree ( {
1284- cwd,
1285- refName : "t3/deleted-base" ,
1286- newRefName : "t3/new-thread" ,
1287- path : pathService . join ( parent , "worktree" ) ,
1288- } )
1289- . pipe ( Effect . flip ) ;
1290-
1291- assert . deepInclude ( error , {
1292- _tag : "GitCommandError" ,
1293- detail : "git worktree add failed" ,
1294- reason : "ref_not_found" ,
1295- } ) ;
1296- assert . include ( error . message , "git worktree add failed (ref_not_found)" ) ;
1297- assert . notInclude ( error . message , "t3/deleted-base" ) ;
1298- } ) ,
1299- ) ;
1300-
13011272 it . effect . each ( [
1302- { label : "worktree add" , args : [ "worktree" , "add" , "../worktree" , "missing" ] } ,
1303- { label : "switch" , args : [ "switch" , "missing" ] } ,
1304- { label : "branch" , args : [ "branch" , "new-branch" , "missing" ] } ,
1305- { label : "checkout -b" , args : [ "checkout" , "-b" , "new-branch" , "missing" ] } ,
1306- { label : "checkout -b of a quoted name" , args : [ "checkout" , "-b" , "new" , "o'brien" ] } ,
1307- { label : "merge-base" , args : [ "merge-base" , "HEAD" , "missing" ] } ,
1308- { label : "rev-parse --verify" , args : [ "rev-parse" , "--verify" , "missing" ] } ,
1309- { label : "log" , args : [ "log" , "-1" , "missing" , "--" ] } ,
1310- ] ) ( "names a ref that does not exist behind a failed $label" , ( { args } ) =>
1311- Effect . gen ( function * ( ) {
1312- const parent = yield * makeTmpDir ( ) ;
1313- const pathService = yield * Path . Path ;
1314- const cwd = pathService . join ( parent , "repo" ) ;
1315- const fileSystem = yield * FileSystem . FileSystem ;
1316- yield * fileSystem . makeDirectory ( cwd ) ;
1317- const driver = yield * GitVcsDriver . GitVcsDriver ;
1318- yield * initRepoWithCommit ( cwd ) ;
1319-
1320- const error = yield * driver
1321- . execute ( {
1322- operation : "GitVcsDriver.test.missingRef" ,
1323- cwd,
1324- args,
1325- env : { LC_ALL : "C" } ,
1326- } )
1327- . pipe ( Effect . flip ) ;
1328-
1329- assert . deepInclude ( error , { reason : "ref_not_found" } ) ;
1330- } ) ,
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+ } ) ,
13311318 ) ;
13321319
13331320 it . effect . each ( [
13341321 // Git cannot tell a missing revision from a missing file in these.
13351322 { label : "an argument that may be a path" , args : [ "log" , "-1" , "missing" ] } ,
1336- { label : "a pathspec" , args : [ "checkout" , "missing" ] } ,
13371323 {
13381324 label : "a pathspec worded like a diagnostic" ,
13391325 args : [ "checkout" , "HEAD" , "--" , "fatal: invalid reference: missing" ] ,
13401326 } ,
13411327 // The tag exists; it names a tree, which git reports in the same words.
1342- { label : "a worktree from a non-commit" , args : [ "worktree" , "add" , "../tree" , "tree-tag" ] } ,
1343- { label : "a non-commit revision" , args : [ "rev-parse" , "--verify" , "tree-tag^{commit}" ] } ,
1328+ {
1329+ label : "a worktree from a non-commit" ,
1330+ args : [ "worktree" , "add" , "tree-worktree" , "tree-tag" ] ,
1331+ } ,
13441332 ] ) ( "leaves $label unclassified rather than calling it a missing ref" , ( { args } ) =>
13451333 Effect . gen ( function * ( ) {
1346- const parent = yield * makeTmpDir ( ) ;
1347- const pathService = yield * Path . Path ;
1348- const cwd = pathService . join ( parent , "repo" ) ;
1349- const fileSystem = yield * FileSystem . FileSystem ;
1350- yield * fileSystem . makeDirectory ( cwd ) ;
1334+ const cwd = yield * makeTmpDir ( ) ;
13511335 const driver = yield * GitVcsDriver . GitVcsDriver ;
13521336 yield * initRepoWithCommit ( cwd ) ;
1353- yield * git ( cwd , [ "tag" , "tree-tag" , "HEAD^{tree}" ] ) ;
1337+ if ( args . includes ( "tree-tag" ) ) {
1338+ yield * git ( cwd , [ "tag" , "tree-tag" , "HEAD^{tree}" ] ) ;
1339+ }
13541340
13551341 const error = yield * driver
13561342 . execute ( {
@@ -3306,18 +3292,6 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
33063292 } ) ,
33073293 ) ;
33083294
3309- it . effect ( "names the missing ref behind a failed switch" , ( ) =>
3310- Effect . gen ( function * ( ) {
3311- const cwd = yield * makeTmpDir ( ) ;
3312- yield * initRepoWithCommit ( cwd ) ;
3313- const driver = yield * GitVcsDriver . GitVcsDriver ;
3314-
3315- const error = yield * driver . switchRef ( { cwd, refName : "deleted-branch" } ) . pipe ( Effect . flip ) ;
3316-
3317- assert . deepInclude ( error , { detail : "git checkout failed" , reason : "ref_not_found" } ) ;
3318- } ) ,
3319- ) ;
3320-
33213295 it . effect ( "still creates and reuses remote tracking branches and allows detached refs" , ( ) =>
33223296 Effect . gen ( function * ( ) {
33233297 const cwd = yield * makeTmpDir ( ) ;
0 commit comments