@@ -920,6 +920,54 @@ it.effect("retries a fetch that lost a ref update to another Git process", () =>
920920 } ) . pipe ( Effect . provide ( layerServerConfig . pipe ( Layer . provideMerge ( NodeServices . layer ) ) ) ) ,
921921) ;
922922
923+ it . effect ( "lets a worktree checkout that is still working run past five minutes" , ( ) =>
924+ Effect . gen ( function * ( ) {
925+ const checkoutStarted = yield * Deferred . make < void > ( ) ;
926+ const checkoutFinished = yield * Deferred . make < void > ( ) ;
927+ const spawner = ChildProcessSpawner . make ( ( command ) =>
928+ Effect . gen ( function * ( ) {
929+ if ( ! ChildProcess . isStandardCommand ( command ) )
930+ return yield * Effect . die ( "expected Git command" ) ;
931+ if ( ! command . args . includes ( "worktree" ) ) return makeSuccessfulHandle ( "" ) ;
932+ yield * Deferred . succeed ( checkoutStarted , undefined ) ;
933+ return ChildProcessSpawner . makeHandle ( {
934+ ...makeSuccessfulHandle ( "" ) ,
935+ exitCode : Deferred . await ( checkoutFinished ) . pipe (
936+ Effect . as ( ChildProcessSpawner . ExitCode ( 0 ) ) ,
937+ ) ,
938+ stderr : Stream . encodeText (
939+ Stream . concat (
940+ Stream . make ( "Updating files: 40% (49052/122629)\n" ) ,
941+ Stream . fromEffect (
942+ Deferred . await ( checkoutFinished ) . pipe (
943+ Effect . as ( "Updating files: 100% (122629/122629), done.\n" ) ,
944+ ) ,
945+ ) ,
946+ ) ,
947+ ) ,
948+ } ) ;
949+ } ) ,
950+ ) ;
951+ const driver = yield * makeGitVcsDriverCore ( ) . pipe (
952+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , spawner ) ,
953+ ) ;
954+ const path = yield * Path . Path ;
955+ const cwd = yield * makeTmpDir ( ) ;
956+ const worktreePath = path . join ( cwd , "worktree" ) ;
957+
958+ const creation = yield * driver
959+ . createWorktree ( { cwd, refName : "main" , newRefName : "t3/slow-checkout" , path : worktreePath } )
960+ . pipe ( Effect . forkChild ) ;
961+ yield * Deferred . await ( checkoutStarted ) ;
962+ yield * TestClock . adjust ( "6 minutes" ) ;
963+ yield * Deferred . succeed ( checkoutFinished , undefined ) ;
964+
965+ const result = yield * Fiber . join ( creation ) ;
966+ assert . equal ( result . worktree . path , worktreePath ) ;
967+ assert . equal ( result . worktree . refName , "t3/slow-checkout" ) ;
968+ } ) . pipe ( Effect . provide ( layerServerConfig . pipe ( Layer . provideMerge ( NodeServices . layer ) ) ) ) ,
969+ ) ;
970+
923971describe ( "rejected git refs" , ( ) => {
924972 const remoteUrl = "https://user:[email protected] /org/secret-repo.git" ; 925973 const failedPush = `error: failed to push some refs to '${ remoteUrl } '` ;
0 commit comments