Working with Pull Requests as a reviewer¶
In order to do a thorough review, it is sometimes desirable to have a local copy of the tests one wishes to review.
Reviewing tests also often results in wanting a few things to be changed. Generally, the reviewer should ask the author to make the desired changes. However, sometimes the original author does not respond to the requests, or the changes are so trivial (e.g. fixing a typo) that bothering the original author seems like a waste of time.
Here is how to do all that.
If it is possible to review the tests without a local copy, but the reviewer still wants to make some simple tweaks to the tests before merging, it is possible to do so via the Github web UI.
Open the pull request. E.g. https://github.com/web-platform-tests/wpt/pull/1234
Go to the view (e.g. https://github.com/web-platform-tests/wpt/pull/1234/files)
Locate the files you wish to change, and click the icon in the upper right corner
Make the desired change
Write a commit message (including a good title) at the bottom
Make sure the radio button is selected.
Note: If the PR predates the introduction of this feature by Github, or if the author of the PR has disabled write-access by reviewers to the PR branch, this may not be available, and your only option would be to commit to a new branch, creating a new PR.
Click the button.
The Normal Way¶
This is how to import the Pull Request’s branch into your existing local checkout of the repository. If you don’t have one, go fork, clone, and configure it.
Move into your local clone:
Add a remote for the PR author’s repo:
git remote add <author-id> git://github.com/<author-id>/<repo-name>.git
Fetch the PR:
git fetch <author-id> <name-of-the-PR-branch>
Checkout that branch:
git checkout <name-of-the-PR-branch>
<name-of-the-PR-branch>can be found by looking for this sentence in on the Github page of the PR:
If all you meant to do was reviewing files locally, you’re all set. If you wish to make changes to the PR branch:
Make changes and commit normally
Push your changes upstream:
git push <author-id> <name-of-the-PR-branch>
Note: If the PR predates the introduction of this feature by Github, or if the author of the PR has disabled write-access by reviewers to the PR branch, this will not work, and you will need to use the alternative described below.
If, instead of modifying the existing PR, you wish to make a new one based on it:
Set up a new branch that contains the existing PR by doing one of the following:
Create a new branch from the tip of the PR:
git branch <your-new-branch> <name-of-the-PR-branch> && git checkout <your-new-branch>
Create a new branch from
masterand merge the PR into it:
git branch <your-new-branch> master && git checkout <your-new-branch> && git merge <name-of-the-PR-branch>
Make changes and commit normally
Push your changes to your repo:
git push origin <your-new-branch>
Go to the Github Web UI to submit a new Pull Request.
Note: You should also close the original pull request.
When you’re done reviewing or making changes,
you can delete the branch:
git branch -d <name-of-the-PR-branch>
-D instead of
-d to delete a branch that has not been merged into master yet).
If you do not expect work with more PRs from the same author,
you may also discard your connection to their repo:
git remote remove <author-id>