Class PullRequestResource

Represents a GitHub pull request resource with chainable async methods.

Implements PromiseLike<GitHubPullRequest> so it can be awaited directly to fetch the pull request info, while also exposing sub-resource methods.

// Await directly to get pull request info
const pr = await gh.org('github').repo('linguist').pullRequest(42);

// Get commits in this pull request
const commits = await gh.org('github').repo('linguist').pullRequest(42).commits();

// Get changed files
const files = await gh.org('github').repo('linguist').pullRequest(42).files();

// Get reviews
const reviews = await gh.org('github').repo('linguist').pullRequest(42).reviews();

// Get review comments (inline diff comments)
const comments = await gh.org('github').repo('linguist').pullRequest(42).reviewComments();

Implements

Methods

  • Adds an inline diff comment to this pull request.

    POST /repos/{owner}/{repo}/pulls/{pull_number}/comments

    Parameters

    • data: AddCommentData

      Comment data. body, commit_id, and path are required.

    • Optionalsignal: AbortSignal

    Returns Promise<GitHubReviewComment>

    The created review comment

  • Submits a review on this pull request.

    POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews

    Parameters

    • data: CreateReviewData

      Review data. event is required ('APPROVE', 'REQUEST_CHANGES', 'COMMENT').

    • Optionalsignal: AbortSignal

    Returns Promise<GitHubReview>

    The submitted review

  • Checks whether the pull request has been merged.

    GET /repos/{owner}/{repo}/pulls/{pull_number}/merge

    Parameters

    • Optionalsignal: AbortSignal

    Returns Promise<boolean>

    true if merged (HTTP 204), false if not merged (HTTP 404)

  • Merges the pull request.

    PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge

    Parameters

    • Optionaldata: MergeData

      Optional merge options: commit_title, commit_message, sha, merge_method

    • Optionalsignal: AbortSignal

    Returns Promise<MergeResult>

    The merge result with SHA and confirmation message

  • Requests reviewers for this pull request.

    POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers

    Parameters

    • data: RequestReviewersData

      Object with reviewers (logins) and/or team_reviewers (slugs)

    • Optionalsignal: AbortSignal

    Returns Promise<GitHubPullRequest>

    The updated pull request

  • Updates this pull request's metadata.

    PATCH /repos/{owner}/{repo}/pulls/{pull_number}

    Parameters

    • data: UpdatePullRequestData

      Fields to update: title, body, state, base, maintainer_can_modify

    • Optionalsignal: AbortSignal

    Returns Promise<GitHubPullRequest>

    The updated pull request