/** * What autopilot asks GitLab and how it reads the answers (autopilot-gitlab-merge-requests). * * Pure, like `ci-jobs.ts`: the driver runs `glab`, this builds the argv and reads the * output. Every read, the retry and the merge go through `glab api`, whose answers are * GitLab's documented REST v4 shapes; `glab mr view` and `glab mr merge` change their * output and defaults between versions — a newer `mr merge` schedules an auto-merge * instead of merging (design D1). Opening uses `glab mr create --fill`, the counterpart * of `gh pr create --fill`, because the API wants a title. * * `:id` is `glab api`'s placeholder for the project of the checkout it runs in, which is * how a self-hosted GitLab works with no host passed (AC-18). * * @module */ import type { Verdict } from './ci-jobs.js'; /** The three reads a dry run may make (AC-16). The retry and the merge carry `--method`, so never match. */ export declare const GLAB_READ_RE: RegExp; export declare function mrCreateArgs(branch: string): string[]; /** The iid in the `/-/merge_requests/` URL `glab mr create` prints, or null (AC-1, AC-2). */ export declare function mrNumber(stdout: string): number | null; export declare function mrViewArgs(n: number): string[]; /** A merge request in the words `gh pr view` uses, so the driver reads both alike (AC-4). */ export interface GitlabMr { state?: 'MERGED' | 'CLOSED' | 'OPEN'; mergeable?: 'CONFLICTING'; /** The source branch's head. */ head: string | null; /** The head pipeline's id, or null when there is none for `head` yet (AC-6). */ pipeline: number | null; } /** `glab api projects/:id/merge_requests/`, or null when it is not a merge request (AC-5). */ export declare function parseMr(stdout: string): GitlabMr | null; export declare function jobsArgs(pipeline: number): string[]; /** A job read as a check: `bucket` is what `gh pr checks` would call it (AC-7). */ export interface GitlabJob { name: string; bucket: string; link?: string; /** `failure_reason`, or null when GitLab gave none. */ reason: string | null; } export interface PipelineJobs { /** The jobs that count — a job a retry replaced is not one of them. */ jobs: GitlabJob[]; /** Whether a job in the pipeline was retried, by anyone (design D2). */ retried: boolean; } /** `glab api …/pipelines//jobs`, or null when it is not a list of jobs (AC-7, AC-8). */ export declare function parseJobs(stdout: string): PipelineJobs | null; /** * The `failure_reason`s that mean no runner ran the job to the end (design D3). An * allowlist, so a reason GitLab adds later reads as tested: this can only ever remove a * false failure. `job_execution_timeout` is left out — a hung test suite is a real one. */ export declare const RUNNER_REASONS: readonly string[]; /** * Whether the failing jobs tested the code, as `classify` decides it on GitHub (AC-9, * AC-11). `fresh` names the pipeline when nothing in it was retried yet (AC-10). */ export declare function classifyJobs(failing: GitlabJob[], pipeline: number, retried: boolean): Verdict; /** Retries every failed and cancelled job in the pipeline — `gh run rerun --failed` (AC-10). */ export declare function retryArgs(pipeline: string): string[]; export declare const TAG_PIPELINES_ARGS: readonly string[]; /** Whether the latest tag pipeline is still going; unreadable is not (AC-12, design D4). */ export declare function releaseInFlight(stdout: string): boolean; /** Merge only `sha`: GitLab refuses when the source branch's head is anything else (AC-13). */ export declare function mergeArgs(n: number, sha: string): string[]; /** Whether the merge call's answer is a merged merge request (AC-14). */ export declare function mergedAnswer(stdout: string): boolean; //# sourceMappingURL=gitlab.d.ts.map