ghpr.el/README.org

3.2 KiB

ghpr.el

ghpr.el provides functionality for reviewing GitHub pull requests from Emacs.

This was inspired by matklad's post on code review, the following discussion, and the mentioned tool prr, which it lifts ideas from. The package aims to bring a reasonable experience of reviewing pull requests from within Emacs, allowing you to run code and tests locally, leverage LSP when exploring newly-added code, and submit reviews against a diff.

This package is not yet stable (version < 1.0). Expect breaking UX changes.

Setup

With straight and use-package:

(use-package ghpr
  :straight (ghpr :type git :host github :repo "priime0/ghpr.el"))

You need a personal access token stored in.authinfo(.gpg) with repo permissions, which will be used to handle interactions with the GitHub API for pull requests, including listing PRs and submitting reviews.

Feature set

Current features:

  • Listing and selecting PRs from minibuffer
  • Viewing a PR diff
  • Writing a body comment and code review comments
  • Submitting the body comment, code review comments, and status (accept, request changes, comment)
  • Checking out the PR branch from ghpr-review-mode
  • Viewing Magit diffs of the PR branch next to ghpr-review-mode

Planned features:

  • Viewing existing review comments, prefixed with <
  • Responding in ghpr-review-mode to existing comments
  • Better UX

Workflow

  • Fetch recent PRs with ghpr-prs. This will open a minibuffer to select one of the PRs.
  • After you select a PR, it will open in a new buffer.
  • Add your comments by inserting new lines (see example).
  • C-c C-o: checkout the changes to run locally or poke around the code.
  • C-c C-d: view a Magit diff of the PR
  • C-c C-a: accept the pull request
  • C-c C-r: request changes to the pull request
  • C-c C-c: comment on the pull request
  • C-c C-k: cancel reviewing the pull request

Example format

  • > prefixes PR metadata and diff content from GitHub
  • < prefixes existing review comments (to be implemented)
  • Lines without prefixes are your review content: the review body above the first >, and individual inline comments in the diff sections
This is the review's body. Markdown *is*
supported throughout the body and your
individual review comments. Lines separated
by a single newline are joined together.

Paragraphs are two newlines of separation.
> [#241] @author: PR title
>
> The description of the PR.
>
> diff --git a/test.md b/test.md
> index aa9e6ef..ae07d61 100644
> --- a/test.md
> +++ b/test.md
> @@ -1,3 +1,5 @@
> +This is an example sentence being added.
> +
This is a comment attached to the line above.
>  This is existing text.
>
> -This is a test modification.
> +This is a test change.
This is a multi-line PR comment
attached to the change above.