Skip to content

Reviewing Pull requests

If a user does not have permission to merge code directly into a repository then you will need to make a Pull Request (PR).
Otherwise known as Merge Request (MR).

In a PR the user requests the owners of teh repository to approve merging in the changes.
The repository owners review teh changes.
They are able to leave comments, approvals or disapprovals.
Sometimes there are pipelines which need to be successful (such as checking LFS objects).

Process

For this we are going to focus on Forgejo only, although all major git hosts are quite similar.

We are going to use this PR as an example:
https://forgejo.skynet.ie/Computer_Society/open-goverance/pulls/77

Review on the Web

Typically a pull request has 3 screens: Conversation, Commits and Files Changed.

img.png

Conversation

This tab contains the initial comment which should include the reasoning behind a PR.
As well as any relevant information that might be useful to the reviewers.

It is this tab which will showcase the summary of the process, any comments, reviews or any new commits added.
If changes are requested they will show up here.
Pipelines passing/failing will also be showcased near the bottom.

NOTE: To view LFS files (like images) in a PR, you need to open them from the source repository OR via the Files Changed tab on the PR.

Commits

The commits tab has a list of all commits in the PR.
Clicking on any of them will show you the commit itself.

Files Changed

This is the core section for the review process.
The files are listed, along side the line by line changes within them.
img.png

If you click the - or + next to teh line numbers you can leave a comment.
img.png

If you select Add single comment then it will just add a comment on teh code.
This is not a review, just a comment.

If you select Start Review then you can leave multiple comments.
They will show up as Pending
img.png

Finishing a Review

To finish the review you need to click the Finish review in the top right, it will state how many comments there are.
At this stage you can select Review/Comment/Request Changes.
(It is greyed out because the PR author cannot approve their own PR)
img.png

If you want to reject the PR, you can either select Request Changes or just leave a comment with the reasons for rejecting it.
img.png

The above is how you would review certain sections of the code and leave comments on it.
Request Changes is more of a blanket statement declaring that the PR isn't ready to be merged, and that the author needs to make changes before it can be merged.

If you want to outright reject the PR entirely, you can go to the Conversation tab and click on the Close pull request/Close with comment button.
If you're closing a PR, it is always best practice to leave a comment on why you are closing it.
img.png

If you've changed your mind on your previous review, navigate to the Conversation subtab and click on the Dismiss Review button.
img.png

NOTE: If there were any changes done to the PR after you left a review, your review will be automatically dismissed with the last review being acknowledged.
img.png

Checkout the code locally

Checking out teh code visually on the web is good for checking minor changes.
However you may want to check out code changes and run them locally on your machine.
To do this you need to use command line git.

if you select View command line instructions near teh bottom of the page.
img.png
It will open up like so.
img.png

This command will allow you to pull down the changes locally.
If Allow edits from maintainers is enabled then you will also be able to push to it if needs be.