Files
orca/src/shared/git-worktree-command-capabilities.ts
T
Neil 34ae0933e4 fix(worktrees): keep creation fast in large repositories (#24346)
* fix(worktrees): remove repeated scans and keep prepared checkouts fresh

* fix(worktrees): reclaim unlocked fallback preparations safely

* refactor(worktrees): simplify creation ownership and idle maintenance

* fix(git): keep ref maintenance armed after an index-only pass

An idle attempt that found the pack index due but refs still cooling down
returned without rescheduling, so loose refs from the arming fetch waited
for the next write instead of the ref cooldown.
2026-10-01 23:37:05 -07:00

41 lines
1.5 KiB
TypeScript

function getGitErrorText(error: unknown): string {
if (typeof error !== 'object' || error === null) {
return error instanceof Error ? error.message : String(error)
}
const values = ['message', 'stderr', 'stdout']
.map((key) => (error as Record<string, unknown>)[key])
.filter((value): value is string => typeof value === 'string')
return values.join('\n')
}
function getGitErrorCode(error: unknown): string | undefined {
return typeof error === 'object' && error !== null && 'code' in error
? String((error as { code?: unknown }).code)
: undefined
}
export function isUnsupportedWorktreeListZError(error: unknown): boolean {
// `-z` is this fixed command's only post-baseline flag, so exit 129 is the
// locale-independent rejection signal on old native, WSL, and SSH Git.
if (getGitErrorCode(error) === '129') {
return true
}
return /(?:unknown|invalid|unrecognized) (?:switch|option).*`?-?z'?/i.test(getGitErrorText(error))
}
export function isUnsupportedRevParsePathFormatError(error: unknown): boolean {
return /(?:unknown|invalid|unrecognized).*(?:--path-format|path-format)/i.test(
getGitErrorText(error)
)
}
export function isUnsupportedWorktreeAddLockReasonError(error: unknown): boolean {
return /\b(?:unknown|invalid|unrecognized) (?:switch|option)[^\r\n]*(?:--)?reason\b/i.test(
getGitErrorText(error)
)
}
export function hasUnsupportedRevParsePathFormatEcho(output: string): boolean {
return output.split(/\r?\n/).some((line) => line.startsWith('--path-format'))
}