import { forkPullNeedsApproval, forkRunNeedsApproval } from "../pull-events"; import type { RepoRow } from "~/lib/types"; /** * A push to a fork PR runs code from its author, the head repository's owner and the pusher, so CI is approved * automatically only when all of them could write to the base. Neither a trusted pusher on an untrusted fork * nor an untrusted pusher on a trusted author's fork skips approval. */ export async function forkPushNeedsApproval( baseRepo: RepoRow, headRepo: RepoRow, authorId: string, pusherId: string | null, ): Promise { if (baseRepo.id === headRepo.id) return false; if (await forkPullNeedsApproval(baseRepo, headRepo, authorId)) return true; return forkRunNeedsApproval(baseRepo, headRepo, pusherId); }