Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.5 KB
Raw Blame
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 command’s only post-baseline flag; exit 129 detects rejection across locales and execution hosts.
  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'))
}