PEP-57: gate — Gitea client only for tasks with a PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cae49d5b54
commit
daa612b0d8
@ -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<GateResult> {
|
||||
export async function prGate(ref: TaskRef, client?: GiteaClient): Promise<GateResult> {
|
||||
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 };
|
||||
|
||||
@ -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";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user