mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
The relay carried its own copies of the worktree-list and unmerged-entry porcelain parsers, and both had drifted from the desktop originals: the relay copy had no `sparse` branch, so SSH sparse checkouts were never marked, and it never C-quote-decoded a conflict path, so a conflicted file with a space or non-ASCII byte was published under its raw quoted name and probed as missing. Move both parsers into src/shared and delete the relay copies, so there is one implementation each. Type the relay's worktree-list plumbing on GitWorktreeInfo instead of Record<string, unknown> so a field-copying step can no longer silently drop a newly parsed field. `isSparse` is a new optional field on the git.listWorktrees result (remote-wire-compatibility Rule 1); Git <2.28 omits the porcelain line and the field stays absent. No new git subcommand or option. Closes #18280
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { isUnsupportedWorktreeListZError } from './git-handler-utils'
|
|
|
|
describe('isUnsupportedWorktreeListZError', () => {
|
|
it('detects an unknown-switch usage error from stderr when the exit code is absent', () => {
|
|
// Isolates the regex fallback: no numeric code, so only the stderr text
|
|
// (a runner that dropped the exit code) can classify the rejection.
|
|
const error = Object.assign(new Error('worktree list -z'), {
|
|
stderr: "error: unknown switch `z'\nusage: git worktree list [<options>]\n"
|
|
})
|
|
expect(isUnsupportedWorktreeListZError(error)).toBe(true)
|
|
})
|
|
|
|
it('detects a localized (non-English) usage error via exit code 129', () => {
|
|
// The SSH remote may run under a non-English locale where the stderr text is
|
|
// translated; the numeric exit code must still classify the -z rejection.
|
|
const error = Object.assign(new Error('worktree list -z'), {
|
|
code: 129,
|
|
stderr: 'Fehler: Unbekannter Schalter »z«\nAufruf: git worktree list [<Optionen>]\n'
|
|
})
|
|
expect(isUnsupportedWorktreeListZError(error)).toBe(true)
|
|
})
|
|
|
|
it('does not classify a fatal (exit 128) error as an unsupported -z rejection', () => {
|
|
const error = Object.assign(new Error('fatal'), {
|
|
code: 128,
|
|
stderr: 'fatal: unable to read tree\n'
|
|
})
|
|
expect(isUnsupportedWorktreeListZError(error)).toBe(false)
|
|
})
|
|
})
|