mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 00:02:29 +00:00
* fix(git): share one error-text reader between the local and relay branch-delete fallbacks The relay and the desktop each carried their own `getErrorText`, and they had drifted: the relay read `message` + `stderr` + `stdout`, the desktop only `message` + `stderr`. A `git branch -d` refusal arriving on `stdout` therefore routed the SSH removal through prune-and-retry while the local removal gave up and preserved the branch. Against a real binary the two agree, because Git prints the refusal through `error()` on every supported version — verified on 2.25.1, 2.38.1, 2.49.1 and 2.55.0, none of which put a byte of it on stdout. What the desktop copy actually missed is that Orca classifies errors it built itself, with the Git output on `.stdout`: `worktree remove`'s submodule retry attaches `git status --porcelain` that way on both paths. The stdout-reading form is also already the shared spelling — `isSubmoduleWorktreeRemovalRefusal` uses it for both hosts — so this converges on it rather than on the shorter one. Move the reader to src/shared/git-command-failure-text.ts and the predicate it feeds to src/shared/git-branch-delete-refusal.ts, and delete all three copies. The predicate carries both refusal wordings live in the supported range: Git through 2.40 says "checked out at", 2.43+ says "used by worktree at". The real-binary contract now pins that boundary: the refusal is recognized, it lands on stderr, and stdout stays empty on every Git in the matrix. * fix(test): consolidate the duplicate worktree import in the parity test
17 lines
753 B
TypeScript
17 lines
753 B
TypeScript
import { readGitCommandFailureText } from './git-command-failure-text'
|
|
|
|
/**
|
|
* `git branch -d/-D` refused because the branch is the HEAD of some worktree.
|
|
*
|
|
* Both wordings are live in Orca's supported range: Git through 2.40 says
|
|
* "Cannot delete branch 'x' checked out at '<path>'", and 2.43+ says "cannot delete
|
|
* branch 'x' used by worktree at '<path>'". Every version prints it through `error()`,
|
|
* so it arrives on stderr. Callers treat a match as "the blocker may be a stale
|
|
* worktree record", prune, and retry once.
|
|
*/
|
|
export function isBranchCheckedOutInWorktreeError(error: unknown): boolean {
|
|
return /cannot delete branch .*(?:used by worktree|checked out)|branch .*is checked out/i.test(
|
|
readGitCommandFailureText(error)
|
|
)
|
|
}
|