@@ -1557,16 +1557,22 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
15571557 } ) ;
15581558
15591559 describe ( "worktree operations" , ( ) => {
1560- for ( const state of [ "new" , "new-missing" , "existing" , "existing-missing" ] as const ) {
1560+ for ( const state of [
1561+ "new" ,
1562+ "new-missing" ,
1563+ "existing" ,
1564+ "existing-missing" ,
1565+ "concurrent" ,
1566+ ] as const ) {
15611567 it . effect ( `cleans up only newly registered worktrees on interruption: ${ state } ` , ( ) =>
15621568 Effect . gen ( function * ( ) {
15631569 const cwd = yield * makeTmpDir ( ) ;
15641570 const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
15651571 const fs = yield * FileSystem . FileSystem ;
15661572 const path = yield * Path . Path ;
15671573 const worktreePath = path . join ( yield * makeTmpDir ( "git-worktrees-" ) , "interrupted" ) ;
1568- const existing = state . startsWith ( "existing" ) ;
1569- if ( existing ) {
1574+ const existing = state . startsWith ( "existing" ) || state === "concurrent" ;
1575+ if ( state . startsWith ( " existing" ) ) {
15701576 yield * git ( cwd , [ "worktree" , "add" , "-b" , "feature/existing" , worktreePath ] ) ;
15711577 if ( state === "existing-missing" ) {
15721578 yield * fs . remove ( worktreePath , { recursive : true } ) ;
@@ -1576,10 +1582,16 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
15761582 const commandFinished = yield * Deferred . make < void > ( ) ;
15771583 const spawner = ChildProcessSpawner . make ( ( command ) =>
15781584 Effect . gen ( function * ( ) {
1579- const handle = yield * delegate . spawn ( command ) ;
1580- return ChildProcess . isStandardCommand ( command ) &&
1585+ const isWorktreeAdd =
1586+ ChildProcess . isStandardCommand ( command ) &&
15811587 command . args . includes ( "worktree" ) &&
1582- command . args . includes ( "add" )
1588+ command . args . includes ( "add" ) ;
1589+ if ( isWorktreeAdd && state === "concurrent" ) {
1590+ yield * git ( cwd , [ "worktree" , "add" , "-b" , "feature/existing" , worktreePath ] ) ;
1591+ yield * writeTextFile ( worktreePath , "uncommitted.txt" , "keep these edits" ) ;
1592+ }
1593+ const handle = yield * delegate . spawn ( command ) ;
1594+ return isWorktreeAdd
15831595 ? ChildProcessSpawner . makeHandle ( {
15841596 ...handle ,
15851597 exitCode : handle . exitCode . pipe (
@@ -1608,7 +1620,13 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
16081620 }
16091621 yield * Fiber . interrupt ( creating ) ;
16101622
1611- assert . equal ( yield * fs . exists ( worktreePath ) , state === "existing" ) ;
1623+ assert . equal ( yield * fs . exists ( worktreePath ) , existing && ! state . endsWith ( "missing" ) ) ;
1624+ if ( state === "concurrent" ) {
1625+ assert . equal (
1626+ yield * fs . readFileString ( path . join ( worktreePath , "uncommitted.txt" ) ) ,
1627+ "keep these edits" ,
1628+ ) ;
1629+ }
16121630 const registered = yield * git ( cwd , [ "worktree" , "list" , "--porcelain" , "-z" ] ) ;
16131631 assert . equal ( registered . includes ( "feature/existing" ) , existing ) ;
16141632 assert . notInclude ( registered , "feature/interrupted" ) ;
@@ -1644,6 +1662,7 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
16441662 baseRefName : initialBranch ,
16451663 } ) ;
16461664
1665+ assert . notInclude ( yield * git ( cwd , [ "worktree" , "list" , "--porcelain" ] ) , "locked" ) ;
16471666 assert . equal ( yield * fs . readFileString ( path . join ( worktreePath , "checkout-workers" ) ) , "0\n" ) ;
16481667 assert . equal ( yield * fs . readFileString ( path . join ( worktreePath , "asset.txt" ) ) , "filtered\n" ) ;
16491668 assert . equal (
0 commit comments