Package to help you perform code reviews from your VC provider. Currently supports Github and basic Gitlab and Bitbucket workflows.
Link to same PR on Github: wandersoncferreira/dotfiles#5
The Emacs everywhere goal continues. These are the main features of
code-review
to help you never leave Emacs to do Pull Request reviews.
- Start review from URL via
code-review-start
- Modern UI using magit-section and transient
- Read Pull Request comments
- Reply to comments
- Include code suggestions
- View
outdated
comments with the right diff hunk context - Approve, Reject or Request Changes for your PRs
- Integrated with
forge-topic-view
viacode-review-forge-pr-at-point
- Fast track commands like "LGTM! Approved"
- Review using single commits to focus on diff
- Set labels on RET. See details Multi value selection
- Set assignee. Use transient
sy
option toassign yourself
to the PR. - Set milestone. See details push access required
- Edit PR title
- Edit PR description body
- Merge your PR. (beta feature) See details merge
- Reactions. See details react to comments
- Promote comments to new issues.
- Save/Resume in-progress Reviews
- Visit binary files in Dired or Remote. Example here
- Mention user with
C-c @
in*code-review-comment*
buffer.
Highly recommend using the transient menu in the *Code Review*
buffer by pressing r
.
The basic workflow:
RET
on a hunk diff line to add a commentRET
on a local comment to editRET
on a previous sent comment to include a replyC-c C-k
on a local comment to remove itr s f
to enable transient and Set a feedbackr a
to approve the PR |r r
to reject the PR |r c
to add comments in the PR
You can include your own bindings to functions like
code-review-set-feedback
, code-review-submit-approve
,
code-review-submit-request-changes
, and code-review-submit-comments
to not rely on the
transient panel. But I think you should see it :]
Take a look at which features are available to each integrated forge here.
Missing something? Please, let us know.
I highly recommend installing code-review
through package.el
.
It's available on MELPA
.
M-x package-install code-review
Then you can either M-x code-review-start
and provide a PR URL or M-x code-review-forge-pr-at-point
if you are in a forge buffer over a PR.
Set code-review-fill-column
to define line wrap comment sections.
If you want to use code-review
in a full buffer you can change the function
used to display the buffer at code-review-new-buffer-window-strategy
e.g. you
can set (setq code-review-new-buffer-window-strategy #'switch-to-buffer)
to
not open a new window.
Set code-review-download-dir
to change the place Code Review will download
binary files in your pull request when you decide to visit them.
If you have trouble with the authinfo process below there is this nice Tweet from @agzam explaining a bit the setup!
code-review
needs a GitHub token to act on your behalf for fetching PRs and
submitting reviews.
- Create a personal access token using GitHub
- Set the
repo
scope as the subscope of repo - If using GitHub enterprise / for business you also need the
write:discussion
read:discussion
scope.
For enterprise users do not forget to change the value of
code-review-github-host
to match the host of your private instance. The
current recommended way to use the package with enterprise solution is through
code-review-forge-pr-at-point
we have a bug identifying enterprise URLs in code-review-start
yet.
Add a line to your auth source files, usually ~/.authinfo.gpg
, with your login
and token:
machine api.github.com login yourlogin^code-review password MYTOKENGOESHERE
- Create a personal access token using Gitlab
- Choose the
api
scope
For enterprise users do not forget to change the value of
code-review-gitlab-host
and code-review-gitlab-graphql-host
to match the
ones of your private instance. The current recommended way to use the package
with enterprise solution is through code-review-forge-pr-at-point
we have a
bug identifying enterprise URLs in code-review-start
yet.
Add a line to your auth source file, usually ~/.authinfo.gpg
, with your login
and token:
machine gitlab.com/api login yourlogin^code-review password MYTOKENGOESHERE
- Create a personal access token using Bitbucket. Go to your Personal Settings -> App Password
- Choose the
pull_request:write
scope
Add a line to your auth source file, usually ~/.authinfo.gpg
, with your login
and token:
machine api.bitbucket.org/2.0 login yourlogin^code-review password MYAPPPASSWORD
You can access the transient panel by hitting r
from any place of the Code Review
buffer.
Binding | Object | Action |
---|---|---|
RET | hunk | Add Comment |
RET | comment | Add Reply |
RET | local comment (not sent to forge yet) | Edit local comment |
C-c C-k | local comment | Delete local comment |
C-c C-c | Comment Buffer | Register your local comment |
C-c C-k | Comment Buffer | Cancel your local comment |
C-c C-r | comment | Add Reaction |
C-c C-n | comment | Promote to new issue |
C-c C-r | pr description | Add Reaction |
RET | reaction (on emoji symbol) | Endorse or Remove Reaction |
RET | Request Reviewer | Request reviewer at point |
You can place code-review-forge-pr-at-point
to a key binding for your convenience:
(define-key forge-topic-mode-map (kbd "C-c r") 'code-review-forge-pr-at-point)
If you are not an Evil user you can set the letter k
, for example, to delete a
local comment or feedback at point.
(define-key code-review-feedback-section-map (kbd "k") 'code-review-section-delete-comment)
(define-key code-review-local-comment-section-map (kbd "k") 'code-review-section-delete-comment)
(define-key code-review-reply-comment-section-map (kbd "k") 'code-review-section-delete-comment)
The package allows you to write integration with other forges to leverage these
functionalities. Take a look at code-review-interfaces.el
to see which functions
need to be implemented.
Thanks Laurent Charignon for the awesome
github-review package and
stewardship. Github Review made me more familiar with the problem domain and
code-review
is an attempt to build on top of it.
Thanks Ag Ibragimov for the amazing idea to use
magit-section
to build a more suitable interface to this problem.