MRs and PRs from VS Code
Intermediate VS Code UI
Why this matters
Reviewing in the editor has one real advantage over the browser: you see the rest of the file. Web diffs show a few lines around each change, which is enough to spot a typo and not enough to notice that the paragraph now contradicts the one above it.
The two extensions
| Platform | Extension | Needs |
|---|---|---|
| GitHub | GitHub Pull Requests and Issues | The Accounts sign-in |
| GitLab | GitLab Workflow | A token with the api scope (lesson 15.3) |
Both add a view to the Activity Bar listing what is open, assigned to you, and waiting for your review.
Creating one
From a branch you have pushed:
- Push the branch, or click Publish Branch.
- Open the extension's view and choose Create Pull Request or Create merge request.
- Fill in the title and description, which the extension pre-fills from your commits and any template in the repository.
- Add reviewers, and mark it a draft if the work is unfinished.
- Create. The extension opens the new merge or pull request as a tab.
The description matters as much here as anywhere: what, why, how to check, and Closes #12 (lesson 9.7). The editor's box is a real editor, which makes writing a proper description easier than in a browser textarea.
Reviewing one
Opening a merge or pull request from the list gives you a description tab, the list of changed files, and the conversation. Two ways to read the change:
- The diff, as in the browser, but in an editor tab.
- Check out the branch: the extension offers this, and then you are reading the real files, with everything else in place. That is the mode worth using for documentation.
Comments work on lines: click the gutter, write, and choose whether to add it now or hold it in a batch. Submitting the review takes the verdict: Comment, Approve, or, on GitHub, Request changes (lesson 10.8).
Suggestions can be written by hand in the comment box using a suggestion fence, which the author then applies with one click on the platform (lesson 9.8).
Pipelines and checks
Both extensions show the pipeline or check status for the current branch in the Status Bar, and list the jobs on the merge or pull request tab. A failing job links to its log, which opens in a tab where the search box is better than a browser's (lesson 14.3).
When the browser is still better
Two cases, and it is worth knowing them rather than fighting the tool:
| Case | Why |
|---|---|
| The merge box | The exact list of unmet requirements, approvals, and the merge options is fuller and more current on the web |
| Anything involving other people's settings | Approval rules, CODEOWNERS, protected branches: read them where they are configured |
A reasonable habit: review in the editor, merge in the browser.
How to do it
The command-line tools do the same things and are excellent for a quick check:
$ gh pr list # GitHub
$ gh pr checkout 42
$ glab mr list # GitLab
$ glab mr checkout 42Checking out someone's branch is one command, and it is the single most useful thing a reviewer of documentation can do.
- The GitHub or GitLab view in the Activity Bar
- Create Pull Request, Checkout Pull Request, Submit Review
- The Status Bar's pipeline or checks indicator
The Pull Requests and Merge Requests tool windows do the same, with a better diff viewer for large changes. See lesson 16.9.
Everything the extension shows is on the merge request page too, and the page is authoritative for the merge box, approval rules and settings (lesson 9.7).
The same for pull requests (lesson 10.7).
Common mistakes
- Reviewing only the diff when the change is a set of instructions. Check out the branch and follow them.
- Leaving comments as individual notes instead of batching them into one review.
- Approving from the editor without saying what you checked (lesson 13.7).
- Assuming the editor shows every merge requirement. The merge box on the web is authoritative.
- Forgetting to switch back to your own branch after checking one out.
Try it yourself
Goal: create and review a merge request without leaving the editor.
- Install and sign in to the extension for your platform.
- From a branch with a commit, create the merge or pull request from the extension, with a real description.
- Open it from the list, and use the extension's checkout action to switch to the branch.
- Leave one comment on a line and submit the review as Comment.
- Open the same merge request in the browser and compare what each view shows you.
Expected result: one merge request created and reviewed from the editor, and a clear sense of which parts you would still do in the browser.
Show solution
Step 5 is the comparison worth making. The editor wins on context, because the whole file is there; the browser wins on the merge box and on anything configured by someone else. Using both deliberately is faster than insisting on either.