Code Reviews

Last updated on 2024-06-27 | Edit this page

Overview

Questions

  • “How do you add reviews to a PR?”
  • “How do you address requested changes?”

Objectives

  • “Become familiar with the code review process on GitHub.”

Request a Review


Requesting a review can be done within a PR. Click on a PR, then click on “Reviewers” on the right-hand side. Here you can type in and select reviewers for your PR.

Reviewers menu on a Pull Request

No reviewers?

At this point, likely no reviewers will appear. You can only directly request reviews from “Collaborators” on your repository.

Add a Review


To add a review to a PR, navigate to the PR in question and click on “Files changed.”

PR page with files changed highlighted

Within this page, when you hover over a line of text, a + button will appear to the left.

PR add comment plus symbol for reviews

Click on the + button to add a comment to that line.

Adding a review comment to line 6

At this point, you can “Cancel”, “Add single comment”, or “Start a review.” If you click “Add single comment”, the comment will be added without rendering a review decision. If you click “Start a review”, this will “start” a review.

Can you see it yet?

At this point, no one can see your review. It is “Pending” until you finish all of your comments.

Once you have finished adding all of the comments, you will need to press the “Review changes” button.

Files changed page with review button highlighted

You will see three options: “Comment”, “Approve”, or “Request changes.”

Greyed out options?

Are you following along on your own PR? You might notice that you cannot approve or request changes. This is because you are the author! GitHub doesn’t allow authors to do either of these actions.

Let’s Review

Partner up with another participant and navigate to their practice repository. Add a few comments to one of their PRs and submit the review, requesting changes.

Address a Review


Review comments can be viewed in the “Conversation” tab as well as in the “Files changed” tab.

PR review comments on Conversation tab
PR review comments on Files changed tab

Incorporating requested changes can be done via command line or through the GitHub GUI. Once addressed and pushed, you can resolved the different conversations and re-request a review.

Fix It

Address the changes your partner requested and re-request a review from them.

And that’s all, folks! You now know much more about GitHub Pull Requests.

Key Points

  • “Code reviews are integrated into GitHub Pull requests.”
  • “Reviewers can approve, request changes, or simply add comments as part of the review process.”