Pull requests
Calls
const open = await forge.pullRequests.list("owner", "repo", { state: "open" });
const pr = await forge.pullRequests.get("owner", "repo", 1234);
const found = await forge.pullRequests.search("owner", "repo", "renovate");
const files = await forge.pullRequests.listFiles("owner", "repo", 1234, { perPage: 100 });
const checks = await forge.pullRequests.listChecks("owner", "repo", 1234);
const comments = await forge.pullRequests.listComments("owner", "repo", 1234);
const created = await forge.pullRequests.create("owner", "repo", {
title: "docs: fix the deploy link",
body: "Closes #42.",
sourceBranch: "fix/deploy-link",
targetBranch: "main",
draft: true,
});
The shape
interface PullRequest extends Issue {
merged: boolean;
draft: boolean;
sourceBranch: string;
targetBranch: string;
mergeCommitSha: string;
headSha: string;
mergeable: boolean | null; // null while the platform is still computing it
mergeStatus: string; // the platform's own word
}
A GitLab merge request has an iid, that is number here. A GitHub pull request is also an issue, so id, labels, author and the dates come from the same place issues get them.
Search returns less
search gives you PullRequestSearchItem: the Issue fields plus merged and draft. No branches, no head SHA, no mergeability. GitHub and Gitea search responses simply do not carry them, and fetching them per row would make one search page cost a whole page of requests. Call get for the row you actually care about.
Changed files
listFiles turns each changed file into a path, a status and two counts:
interface PullRequestFile {
path: string;
status: "added" | "modified" | "removed" | "renamed" | "copied" | "unknown";
additions: number | null;
deletions: number | null;
}
No patches. GitLab withholds counts for a collapsed or oversized diff, and those come back as null. Never as zero, zero would be a lie.
Checks
listChecks reads whatever the platform pins to the head revision: GitHub check runs for the head SHA, GitLab merge request pipelines for the current head, Gitea commit statuses. Each one is a PullRequestCheck with a name, a lifecycle status and a terminal conclusion, the same two enums CI runs use.
Comments
listComments on a pull request is the discussion, not the review threads. On GitHub and Gitea it is the same endpoint as issue comments. Inline review comments live under threads.