GhEx.PullRequests (gh_ex v0.1.0)

Copy Markdown View Source

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 on a pull request. attrs sets event (APPROVE, REQUEST_CHANGES, COMMENT), body, comments.

Gets a single pull request by number.

Lists pull requests in a repository. Use params: for state, base, head, and the other query options.

Lists the files changed in a pull request.

Lists the reviews on a pull request.

Merges a pull request. attrs may set commit_title, commit_message, and merge_method ("merge", "squash", or "rebase").

Updates a pull request. attrs may set title, body, state, base, and so on.

Types

number_ref()

@type number_ref() :: integer() | String.t()

Functions

create(client, owner, repo, attrs, opts \\ [])

@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, ...).

create_review(client, owner, repo, number, attrs, opts \\ [])

@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.

get(client, owner, repo, number, opts \\ [])

Gets a single pull request by number.

list(client, owner, repo, opts \\ [])

Lists pull requests in a repository. Use params: for state, base, head, and the other query options.

list_files(client, owner, repo, number, opts \\ [])

@spec list_files(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) ::
  GhEx.REST.result()

Lists the files changed in a pull request.

list_reviews(client, owner, repo, number, opts \\ [])

@spec list_reviews(GhEx.Client.t(), String.t(), String.t(), number_ref(), keyword()) ::
  GhEx.REST.result()

Lists the reviews on a pull request.

merge(client, owner, repo, number, attrs \\ %{}, opts \\ [])

Merges a pull request. attrs may set commit_title, commit_message, and merge_method ("merge", "squash", or "rebase").

update(client, owner, repo, number, attrs, opts \\ [])

@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.