diff --git a/packages/core/src/ci.ts b/packages/core/src/ci.ts index 32a123c9..06a5a5cb 100644 --- a/packages/core/src/ci.ts +++ b/packages/core/src/ci.ts @@ -137,9 +137,10 @@ export interface GateResult { * Gate for review and merge: the task's PR head has green checks and no conflicts. A task * without a PR or a project without checks passes (the card says "проверки не настроены"). */ -export async function prGate(ref: TaskRef, gitea: GiteaClient = giteaForBot()): Promise { +export async function prGate(ref: TaskRef, client?: GiteaClient): Promise { const n = taskPrNumber(ref.project, ref.task.prUrl); if (!n) return { ok: true, summary: null, pull: null }; + const gitea = client ?? giteaForBot(); const { giteaOwner: o, giteaRepo: r } = ref.project; const pull = await gitea.getPullRequest(o, r, n); if (pull.merged) return { ok: true, summary: null, pull }; diff --git a/packages/runner/src/ci-feedback.ts b/packages/runner/src/ci-feedback.ts index 57311b9c..0c76c0ec 100644 --- a/packages/runner/src/ci-feedback.ts +++ b/packages/runner/src/ci-feedback.ts @@ -183,7 +183,9 @@ export async function pollChecks(db: Db, gitea: GiteaClient = giteaForBot()): Pr * Merge on "Accept" (PEP-57): only with green checks of the PR head and no conflicts. * Throws with the reason for the PM; a task without a PR has nothing to merge. */ -export async function mergeTaskPr(ref: TaskRef, gitea: GiteaClient = giteaForBot()): Promise<"merged" | "already" | "no_pr"> { +export async function mergeTaskPr(ref: TaskRef, client?: GiteaClient): Promise<"merged" | "already" | "no_pr"> { + if (!taskPrNumber(ref.project, ref.task.prUrl)) return "no_pr"; + const gitea = client ?? giteaForBot(); const gate = await prGate(ref, gitea); if (!gate.pull) return "no_pr"; if (gate.pull.merged) return "already";