openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
40 lines (39 loc) • 1.2 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs";
//#region src/gateway/github-repository-target.ts
function resolveGitHubForkParent(e) {
if (!isRecord(e) || e.fork !== true || !isRecord(e.parent)) return;
const t = isRecord(e.parent.owner) ? e.parent.owner : void 0;
const n = normalizeOptionalString(t?.login);
const r = normalizeOptionalString(e.parent.name);
return n && r ? {
owner: n,
repo: r
} : void 0;
}
/** Projects GitHub's repository response into the canonical push/head/base relationship. */
function resolveGitHubRepositoryTarget(e, t) {
if (!isRecord(e)) return;
const n = normalizeOptionalString(e.default_branch);
if (e.fork !== true) return n ? {
fork: false,
push: t,
pullRequest: {
...t,
defaultBranch: n
}
} : void 0;
const r = resolveGitHubForkParent(e);
const i = isRecord(e.parent) ? e.parent : void 0;
const a = normalizeOptionalString(i?.default_branch);
return r && a ? {
fork: true,
push: t,
pullRequest: {
...r,
defaultBranch: a
}
} : void 0;
}
//#endregion
export { resolveGitHubRepositoryTarget as n, resolveGitHubForkParent as t };