mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 08:03:28 +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) {
|
||||
|
||||
@@ -202,7 +202,14 @@ describe('collectWorktreeTrashSweepRoots', () => {
|
||||
try {
|
||||
expect(
|
||||
collectWorktreeTrashSweepRoots(
|
||||
[repo({ path: '\\\\wsl.localhost\\Ubuntu\\home\\dev\\orca' })],
|
||||
[
|
||||
repo({ path: '\\\\wsl.localhost\\Ubuntu\\home\\dev\\orca' }),
|
||||
repo({
|
||||
id: 'repo-2',
|
||||
path: 'C:\\code\\orca',
|
||||
worktreeBasePath: '\\\\wsl.localhost\\Ubuntu\\home\\dev\\trees'
|
||||
})
|
||||
],
|
||||
settings
|
||||
)
|
||||
).toEqual([])
|
||||
|
||||
@@ -163,7 +163,10 @@ export function collectWorktreeTrashSweepRoots(
|
||||
continue
|
||||
}
|
||||
try {
|
||||
roots.add(computeWorkspaceRoot(repo.path, getWorktreePathSettings(repo, settings)))
|
||||
const workspaceRoot = computeWorkspaceRoot(repo.path, getWorktreePathSettings(repo, settings))
|
||||
if (!parseWslPath(workspaceRoot)) {
|
||||
roots.add(workspaceRoot)
|
||||
}
|
||||
} catch {
|
||||
// A repo with an unusable configured base path simply has no trash root to sweep.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user