@@ -3657,133 +3657,6 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
36573657 } ) ,
36583658 ) ;
36593659
3660- it . effect ( "keeps a locked worktree whose lock can't be read" , ( ) =>
3661- Effect . gen ( function * ( ) {
3662- const cwd = yield * makeTmpDir ( ) ;
3663- const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
3664- const pathService = yield * Path . Path ;
3665- const fileSystem = yield * FileSystem . FileSystem ;
3666- const worktreePath = pathService . join ( yield * makeTmpDir ( "git-worktrees-" ) , "linked" ) ;
3667- const driver = yield * GitVcsDriver . GitVcsDriver ;
3668- yield * driver . createWorktree ( {
3669- cwd,
3670- path : worktreePath ,
3671- refName : initialBranch ,
3672- newRefName : "feature/linked" ,
3673- } ) ;
3674- // Git counts the lock file's existence; one that can't be read still locks.
3675- const lockFile = pathService . join (
3676- yield * git ( worktreePath , [ "rev-parse" , "--absolute-git-dir" ] ) ,
3677- "locked" ,
3678- ) ;
3679- NodeFS . mkdirSync ( lockFile ) ;
3680-
3681- const result = yield * Effect . result (
3682- driver . removeWorktree ( { cwd, path : worktreePath , force : true } ) ,
3683- ) ;
3684-
3685- assert . isTrue ( Result . isFailure ( result ) ) ;
3686- assert . equal ( yield * fileSystem . exists ( pathService . join ( worktreePath , "README.md" ) ) , true ) ;
3687- } ) ,
3688- ) ;
3689-
3690- it . effect ( "keeps edits in a worktree whose core.worktree points elsewhere" , ( ) =>
3691- Effect . gen ( function * ( ) {
3692- const cwd = yield * makeTmpDir ( ) ;
3693- const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
3694- const pathService = yield * Path . Path ;
3695- const fileSystem = yield * FileSystem . FileSystem ;
3696- const worktreePath = pathService . join ( yield * makeTmpDir ( "git-worktrees-" ) , "linked" ) ;
3697- const driver = yield * GitVcsDriver . GitVcsDriver ;
3698- yield * driver . createWorktree ( {
3699- cwd,
3700- path : worktreePath ,
3701- refName : initialBranch ,
3702- newRefName : "feature/linked" ,
3703- } ) ;
3704- // A plain `git status` in the worktree now inspects the clean main checkout.
3705- yield * git ( cwd , [ "config" , "extensions.worktreeConfig" , "true" ] ) ;
3706- yield * git ( worktreePath , [ "config" , "--worktree" , "core.worktree" , cwd ] ) ;
3707- yield * writeTextFile ( worktreePath , "README.md" , "uncommitted\n" ) ;
3708-
3709- const result = yield * Effect . result ( driver . removeWorktree ( { cwd, path : worktreePath } ) ) ;
3710-
3711- assert . isTrue ( Result . isFailure ( result ) ) ;
3712- assert . equal (
3713- yield * fileSystem . readFileString ( pathService . join ( worktreePath , "README.md" ) ) ,
3714- "uncommitted\n" ,
3715- ) ;
3716- } ) ,
3717- ) ;
3718-
3719- // Git for Windows reads a junction as a plain folder, so the swap is invisible
3720- // to `status`. Elsewhere the link is a symlink, which shows up as a typechange
3721- // and makes a non-forced remove refuse.
3722- it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) !== "win32" ) (
3723- "removes a worktree whose tracked folder was replaced by a junction" ,
3724- ( ) =>
3725- Effect . gen ( function * ( ) {
3726- const cwd = yield * makeTmpDir ( ) ;
3727- const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
3728- yield * writeTextFile ( cwd , "src/keep.txt" , "keep\n" ) ;
3729- yield * git ( cwd , [ "add" , "src" ] ) ;
3730- yield * git ( cwd , [ "commit" , "-m" , "add src" ] ) ;
3731- const fileSystem = yield * FileSystem . FileSystem ;
3732- const pathService = yield * Path . Path ;
3733- const worktreePath = pathService . join ( yield * makeTmpDir ( "git-worktrees-" ) , "linked" ) ;
3734- const driver = yield * GitVcsDriver . GitVcsDriver ;
3735- yield * driver . createWorktree ( {
3736- cwd,
3737- path : worktreePath ,
3738- refName : initialBranch ,
3739- newRefName : "feature/linked" ,
3740- } ) ;
3741- // Same bytes as the checkout, so Git sees neither a change nor an untracked file.
3742- const outside = yield * makeTmpDir ( "git-worktree-link-target-" ) ;
3743- NodeFS . copyFileSync (
3744- pathService . join ( worktreePath , "src" , "keep.txt" ) ,
3745- pathService . join ( outside , "keep.txt" ) ,
3746- ) ;
3747- NodeFS . rmSync ( pathService . join ( worktreePath , "src" ) , { recursive : true } ) ;
3748- NodeFS . symlinkSync ( outside , pathService . join ( worktreePath , "src" ) , "junction" ) ;
3749-
3750- yield * driver . removeWorktree ( { cwd, path : worktreePath } ) ;
3751-
3752- assert . deepEqual ( NodeFS . readdirSync ( pathService . dirname ( worktreePath ) ) , [ ] ) ;
3753- assert . equal (
3754- yield * fileSystem . readFileString ( pathService . join ( outside , "keep.txt" ) ) ,
3755- "keep\n" ,
3756- ) ;
3757- } ) ,
3758- ) ;
3759-
3760- it . effect ( "leaves a folder alone that only shares the worktree's short name" , ( ) =>
3761- Effect . gen ( function * ( ) {
3762- const cwd = yield * makeTmpDir ( ) ;
3763- const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
3764- const pathService = yield * Path . Path ;
3765- const fileSystem = yield * FileSystem . FileSystem ;
3766- const driver = yield * GitVcsDriver . GitVcsDriver ;
3767- const worktreePath = pathService . join ( yield * makeTmpDir ( "git-worktrees-" ) , "short" ) ;
3768- yield * driver . createWorktree ( {
3769- cwd,
3770- path : worktreePath ,
3771- refName : initialBranch ,
3772- newRefName : "feature/short" ,
3773- } ) ;
3774- // Unrelated to the worktree, but resolving "short" against cwd lands here.
3775- const outside = yield * makeTmpDir ( "git-worktree-link-target-" ) ;
3776- const unrelated = pathService . join ( cwd , "short" ) ;
3777- NodeFS . mkdirSync ( unrelated ) ;
3778- NodeFS . symlinkSync ( outside , pathService . join ( unrelated , "linked" ) , "junction" ) ;
3779-
3780- yield * Effect . result ( driver . removeWorktree ( { cwd, path : "short" , force : true } ) ) ;
3781-
3782- assert . isTrue ( NodeFS . lstatSync ( pathService . join ( unrelated , "linked" ) ) . isSymbolicLink ( ) ) ;
3783- assert . equal ( yield * fileSystem . exists ( worktreePath ) , true ) ;
3784- } ) ,
3785- ) ;
3786-
37873660 it . effect ( "allows worktree removal to run longer than the default command timeout" , ( ) =>
37883661 Effect . gen ( function * ( ) {
37893662 const delegate = yield * ChildProcessSpawner . ChildProcessSpawner ;
0 commit comments