Fix worktree path comparison after base-path rebase
This commit is contained in:
parent
7f1c680597
commit
94ac6cccbf
|
|
@ -266,6 +266,16 @@ describe('areWorktreePathsEqual', () => {
|
|||
it('keeps POSIX path comparison case-sensitive', () => {
|
||||
expect(areWorktreePathsEqual('/tmp/Worktree', '/tmp/worktree', 'linux')).toBe(false)
|
||||
})
|
||||
|
||||
it('treats macOS /private/tmp git paths as matching /tmp workspace paths', () => {
|
||||
expect(
|
||||
areWorktreePathsEqual(
|
||||
'/private/tmp/orca-proof/worktrees/repo/feature',
|
||||
'/tmp/orca-proof/worktrees/repo/feature',
|
||||
'darwin'
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('shouldSetDisplayName', () => {
|
||||
|
|
|
|||
|
|
@ -190,8 +190,8 @@ export function areWorktreePathsEqual(
|
|||
// create spuriously fails until the next full reload repopulates state.
|
||||
return left.toLowerCase() === right.toLowerCase()
|
||||
}
|
||||
const left = posix.normalize(posix.resolve(leftPath))
|
||||
const right = posix.normalize(posix.resolve(rightPath))
|
||||
const left = normalizePosixWorktreePathForComparison(leftPath, platform)
|
||||
const right = normalizePosixWorktreePathForComparison(rightPath, platform)
|
||||
return left === right
|
||||
}
|
||||
|
||||
|
|
@ -201,6 +201,20 @@ function looksLikeWindowsPath(pathValue: string): boolean {
|
|||
)
|
||||
}
|
||||
|
||||
function normalizePosixWorktreePathForComparison(
|
||||
pathValue: string,
|
||||
platform: NodeJS.Platform
|
||||
): string {
|
||||
const normalized = posix.normalize(posix.resolve(pathValue))
|
||||
if (platform !== 'darwin') {
|
||||
return normalized
|
||||
}
|
||||
if (normalized === '/private/tmp') {
|
||||
return '/tmp'
|
||||
}
|
||||
return normalized.startsWith('/private/tmp/') ? normalized.slice('/private'.length) : normalized
|
||||
}
|
||||
|
||||
function getRuntimePathOps(
|
||||
repoPath: string,
|
||||
workspaceDir: string
|
||||
|
|
|
|||
|
|
@ -1763,7 +1763,7 @@ describe('registerWorktreeHandlers', () => {
|
|||
}
|
||||
const fsProvider = {
|
||||
stat: vi.fn().mockImplementation(async (pathValue: string) => {
|
||||
if (pathValue === '/remote/repo/../fix-title') {
|
||||
if (pathValue === '/remote/fix-title') {
|
||||
return { size: 0, type: 'directory', mtime: 0 }
|
||||
}
|
||||
const error = new Error('missing') as Error & { code: string }
|
||||
|
|
@ -1792,11 +1792,11 @@ describe('registerWorktreeHandlers', () => {
|
|||
expect(provider.addWorktree).toHaveBeenCalledWith(
|
||||
'/remote/repo',
|
||||
'feature/fix',
|
||||
'/remote/repo/../fix-title-2',
|
||||
'/remote/fix-title-2',
|
||||
{ checkoutExistingBranch: true }
|
||||
)
|
||||
expect(mux.request).toHaveBeenCalledWith('session.registerRoot', {
|
||||
rootPath: '/remote/repo/../fix-title-2'
|
||||
rootPath: '/remote/fix-title-2'
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue