mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 00:03:47 +00:00
fix(worktrees): keep WSL trash on its owning host
This commit is contained in:
@@ -489,6 +489,24 @@ branch refs/heads/main
|
||||
expect(getGitCalls()).toContain('git worktree remove /repo-feature')
|
||||
})
|
||||
|
||||
it('does not rename a WSL checkout configured for a native Windows repo', async () => {
|
||||
const originalPlatform = process.platform
|
||||
const worktreePath = '\\\\wsl.localhost\\Ubuntu\\home\\dev\\feature'
|
||||
Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' })
|
||||
try {
|
||||
mockGitCommands({})
|
||||
|
||||
await removeWorktree('C:\\repo', worktreePath, false, {
|
||||
knownRemovedWorktree: { branch: '', head: '', locked: false }
|
||||
})
|
||||
|
||||
expect(moveWorktreeDirectoryToTrashMock).not.toHaveBeenCalled()
|
||||
expect(getGitCalls()).toEqual([`git worktree remove ${worktreePath}`])
|
||||
} finally {
|
||||
Object.defineProperty(process, 'platform', { configurable: true, value: originalPlatform })
|
||||
}
|
||||
})
|
||||
|
||||
it('passes one --force before the worktree path for dirty-file removal', async () => {
|
||||
mockGitCommands({
|
||||
'git worktree list --porcelain': {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
restoreWorktreeDirectoryFromTrash,
|
||||
scheduleWorktreeTrashDeletion
|
||||
} from '../worktree-trash'
|
||||
import { parseWslPath } from '../wsl'
|
||||
import type {
|
||||
GitWorktreeInfo,
|
||||
LocalBaseRefRefreshResult,
|
||||
@@ -1187,7 +1188,7 @@ async function tryRemoveWorktreeWithDeferredDirectoryDeletion(
|
||||
options: RemoveWorktreeOptions
|
||||
): Promise<boolean> {
|
||||
// Why: WSL-owned checkouts are deleted inside the distro, so Node on Windows must not rename them.
|
||||
if (options.wslDistro) {
|
||||
if (options.wslDistro || parseWslPath(worktreePath)) {
|
||||
return false
|
||||
}
|
||||
if (!force) {
|
||||
|
||||
Reference in New Issue
Block a user