mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: MarkXian <mark-xian@foxmail.com>
23 lines
971 B
TypeScript
23 lines
971 B
TypeScript
function getErrorText(error: unknown): string {
|
|
if (typeof error === 'object' && error !== null) {
|
|
const parts: string[] = []
|
|
for (const field of ['message', 'stderr', 'stdout'] as const) {
|
|
const value = (error as Record<string, unknown>)[field]
|
|
if (typeof value === 'string' && value) {
|
|
parts.push(value)
|
|
}
|
|
}
|
|
return parts.join('\n')
|
|
}
|
|
return String(error)
|
|
}
|
|
|
|
// Why: `git worktree remove` (non-force) categorically refuses any worktree
|
|
// containing an initialised submodule, even when parent and submodule are
|
|
// fully clean (validate_no_submodules, Git >= 2.17). Callers re-prove
|
|
// cleanliness and retry with --force. Both the local runner and the relay pin
|
|
// English git output (UNTRANSLATED_GIT_OUTPUT_ENV), so text matching is stable.
|
|
export function isSubmoduleWorktreeRemovalRefusal(error: unknown): boolean {
|
|
return /working trees containing submodules cannot be moved or removed/i.test(getErrorText(error))
|
|
}
|