mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 17:47:40 +00:00
* [comment audit] Shorten daemon, hook, and emulator comments [skip ci] * [comment audit] Shorten VM, conversation, SQLite, and theme-import comments [skip ci] * [comment audit] Tighten Git execution and source-control comment contracts [skip ci] * [comment audit] Clarify repository probes and maintenance comments [skip ci] * [comment audit] Shorten status, diff-cache, and checkout comments [skip ci] * [comment audit] Clarify worktree lifecycle and WSL routing comments [skip ci] * [comment audit] Shorten forge identity and review-refresh comments [skip ci] * [comment audit] Tighten hosted-review client comment contracts [skip ci] * [comment audit] Clarify GitLab compatibility and review comments [skip ci] * [comment audit] Tighten hook ownership and watchdog rationale [skip ci] * [comment audit] Condense host and integration compatibility comments [skip ci] * [comment audit] Clarify IPC authority and remote-routing rationale [skip ci] * [comment audit] Finalize file-import and containment comment cleanup * [comment audit] Fix stale Jira type imports blocking full CI --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
type CompareBaseGitExec = (args: string[]) => Promise<{ stdout: string }>
|
|
|
|
/** Keep a locally resolvable base after fetch failure; dropping it can make fork reviews diff against themselves. */
|
|
export async function fetchCompareBaseRefWithLocalFallback(options: {
|
|
compareBaseRef: string | undefined
|
|
fetchCompareBaseRef: (compareBaseRef: string) => Promise<void>
|
|
gitExec: CompareBaseGitExec
|
|
/** Log prefix identifying the calling resolver, e.g. `[github:resolvePrStartPoint]`. */
|
|
logLabel: string
|
|
/** Resolver-specific fields (remote, branch, review id) merged into the warning. */
|
|
logContext: Record<string, unknown>
|
|
}): Promise<boolean> {
|
|
if (!options.compareBaseRef) {
|
|
return false
|
|
}
|
|
try {
|
|
await options.fetchCompareBaseRef(options.compareBaseRef)
|
|
return true
|
|
} catch (error) {
|
|
const localBaseResolved = await compareBaseRefResolvesLocally(
|
|
options.gitExec,
|
|
options.compareBaseRef
|
|
)
|
|
console.warn(`${options.logLabel} optional compare-base fetch failed`, {
|
|
...options.logContext,
|
|
localBaseResolved,
|
|
error: error instanceof Error ? error.message.split('\n')[0] : String(error)
|
|
})
|
|
return localBaseResolved
|
|
}
|
|
}
|
|
|
|
async function compareBaseRefResolvesLocally(
|
|
gitExec: CompareBaseGitExec,
|
|
compareBaseRef: string
|
|
): Promise<boolean> {
|
|
try {
|
|
const { stdout } = await gitExec(['rev-parse', '--verify', `${compareBaseRef}^{commit}`])
|
|
return stdout.trim().length > 0
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|