Skip to content

Commit 8145f3b

Browse files
maharshi365Colin4k1024
authored andcommitted
fix(opencode): cleanup orphaned worktree directories (anomalyco#12399)
1 parent 100cabb commit 8145f3b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/opencode/src/worktree/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,13 @@ export namespace Worktree {
411411
if (key === directory) return item
412412
}
413413
})()
414+
414415
if (!entry?.path) {
415-
throw new RemoveFailedError({ message: "Worktree not found" })
416+
const directoryExists = await exists(directory)
417+
if (directoryExists) {
418+
await fs.rm(directory, { recursive: true, force: true })
419+
}
420+
return true
416421
}
417422

418423
const removed = await $`git worktree remove --force ${entry.path}`.quiet().nothrow().cwd(Instance.worktree)

0 commit comments

Comments
 (0)