Convenience functions for the GitHub Pull Requests REST API.
Each function is a thin wrapper over GhEx.REST that fills in the endpoint
path. They return the same {:ok, body, meta} / {:error, reason} shape as
GhEx.REST and pass opts through to Req, so :params, headers, and a
Req.Test plug all work. For an endpoint without a wrapper, call GhEx.REST
directly.
Summary
Functions
Creates a pull request. attrs is the JSON body (title, head, base, body, draft, ...).
Creates a review comment anchored to a pull request diff.
Creates a review on a pull request. attrs sets event (APPROVE, REQUEST_CHANGES, COMMENT), body, comments.
Gets a single pull request by number.
Gets a pull request's unified diff as a string.
Gets the current result of an asynchronous merge request.
Gets a pull request's mailbox-format patch as a string.
Checks whether a pull request has been merged.
Lists pull requests in a repository. Use params: for state, base, head,
and the other query options.
Lists review comments on a pull request.
Lists the commits on a pull request. GitHub returns at most 250 commits.
Lists the files changed in a pull request.
Lists the reviews on a pull request.
Merges a standalone pull request using GitHub's legacy synchronous endpoint.
Submits an asynchronous merge request.
Removes review requests from users and/or teams.
Replies to a top-level review comment.
Requests reviews from users and/or teams.
Auto-paginates pull requests in a repository into a lazy Stream of
individual pull requests (see GhEx.REST.stream/3).
Auto-paginates a pull request's review comments into a lazy Stream.
Auto-paginates the commits on a pull request into a lazy Stream.
Auto-paginates the files changed in a pull request into a lazy Stream.
Auto-paginates the reviews on a pull request into a lazy Stream.
Updates a pull request. attrs may set title, body, state, base, and so on.
Types
Functions
@spec create(GhEx.Client.t(), String.t(), String.t(), map(), keyword()) :: GhEx.REST.result()
Creates a pull request. attrs is the JSON body (title, head, base, body, draft, ...).
@spec create_comment( GhEx.Client.t(), String.t(), String.t(), number_ref(), map(), keyword() ) :: GhEx.REST.result()
Creates a review comment anchored to a pull request diff.
attrs requires body, commit_id, and path. For a line comment, provide
line and side ("LEFT" or "RIGHT"). A multi-line comment also uses
start_line and start_side. For a file-level comment, set
subject_type: "file"; line is then optional. GitHub is closing down the
older position parameter, so prefer the line-based fields.
@spec create_review( GhEx.Client.t(), String.t(), String.t(), number_ref(), map(), keyword() ) :: GhEx.REST.result()
Creates a review on a pull request. attrs sets event (APPROVE, REQUEST_CHANGES, COMMENT), body, comments.
@spec get(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Gets a single pull request by number.
@spec get_diff(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Gets a pull request's unified diff as a string.
This forces GitHub's application/vnd.github.diff media type while
preserving any other request headers supplied through opts.
@spec get_merge_result( GhEx.Client.t(), String.t(), String.t(), number_ref(), String.t(), keyword() ) :: GhEx.REST.result()
Gets the current result of an asynchronous merge request.
Pending results are retained by GitHub for 24 hours after their most recent update.
@spec get_patch(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Gets a pull request's mailbox-format patch as a string.
This forces GitHub's application/vnd.github.patch media type while
preserving any other request headers supplied through opts.
@spec is_merged(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Checks whether a pull request has been merged.
Returns {:ok, true, meta} for GitHub's 204 response and
{:ok, false, meta} for its 404 response. Other failures retain the
standard {:error, reason} shape.
@spec list(GhEx.Client.t(), String.t(), String.t(), keyword()) :: GhEx.REST.result()
Lists pull requests in a repository. Use params: for state, base, head,
and the other query options.
@spec list_comments(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Lists review comments on a pull request.
These are comments anchored to a diff, not issue comments from the pull
request's Conversation tab. Use params: for sort, direction, and
since.
@spec list_commits(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Lists the commits on a pull request. GitHub returns at most 250 commits.
@spec list_files(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Lists the files changed in a pull request.
@spec list_reviews(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: GhEx.REST.result()
Lists the reviews on a pull request.
@spec merge(GhEx.Client.t(), String.t(), String.t(), number_ref(), map(), keyword()) :: GhEx.REST.result()
Merges a standalone pull request using GitHub's legacy synchronous endpoint.
attrs may set commit_title, commit_message, and merge_method
("merge", "squash", or "rebase"). This endpoint cannot merge a stacked
pull request; use merge_async/6 for stacks.
@spec merge_async( GhEx.Client.t(), String.t(), String.t(), number_ref(), map(), keyword() ) :: GhEx.REST.result()
Submits an asynchronous merge request.
For a stacked pull request, GitHub merges the selected pull request and every
unmerged pull request below it as one atomic operation. attrs may set
merge_method ("merge", "squash", or "rebase"), merge_action
("default", "direct_merge", or "merge_queue"), commit_title,
commit_message, and sha.
A 202 response has status "pending" and includes a UUID. Poll it with
get_merge_result/6 until the status is "merged", "enqueued", or
"failed".
GitHub may return a 409 with the existing pending request when a merge is
already running. As with every non-2xx REST response in gh_ex, that is returned
as {:error, %GhEx.Error{}}; the pending result remains available in the
error's body field.
@spec remove_requested_reviewers( GhEx.Client.t(), String.t(), String.t(), number_ref(), map(), keyword() ) :: GhEx.REST.result()
Removes review requests from users and/or teams.
attrs accepts the same reviewers and team_reviewers arrays as
request_reviewers/6.
@spec reply_to_comment( GhEx.Client.t(), String.t(), String.t(), number_ref(), number_ref(), String.t(), keyword() ) :: GhEx.REST.result()
Replies to a top-level review comment.
GitHub does not support replies to replies; comment_id must identify the
top-level comment in the thread.
@spec request_reviewers( GhEx.Client.t(), String.t(), String.t(), number_ref(), map(), keyword() ) :: GhEx.REST.result()
Requests reviews from users and/or teams.
attrs may contain reviewers, an array of user logins, and
team_reviewers, an array of team slugs.
@spec stream(GhEx.Client.t(), String.t(), String.t(), keyword()) :: Enumerable.t()
Auto-paginates pull requests in a repository into a lazy Stream of
individual pull requests (see GhEx.REST.stream/3).
@spec stream_comments( GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword() ) :: Enumerable.t()
Auto-paginates a pull request's review comments into a lazy Stream.
@spec stream_commits(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: Enumerable.t()
Auto-paginates the commits on a pull request into a lazy Stream.
@spec stream_files(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: Enumerable.t()
Auto-paginates the files changed in a pull request into a lazy Stream.
@spec stream_reviews(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) :: Enumerable.t()
Auto-paginates the reviews on a pull request into a lazy Stream.
@spec update(GhEx.Client.t(), String.t(), String.t(), number_ref(), map(), keyword()) :: GhEx.REST.result()
Updates a pull request. attrs may set title, body, state, base, and so on.