Git Course 0%

MRs and PRs from VS Code

Intermediate VS Code UI ≈ 10 min

What you will learn

  • What the platform extensions add to the editor
  • How to review a change with the whole file in front of you
  • When to stay in the browser instead

After this lesson you can

  • I can review a colleague's change from the editor, with more context than the web diff gives

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:

  1. Push the branch, or click Publish Branch.
  2. Open the extension's view and choose Create Pull Request or Create merge request.
  3. Fill in the title and description, which the extension pre-fills from your commits and any template in the repository.
  4. Add reviewers, and mark it a draft if the work is unfinished.
  5. 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:

Terminal
$ gh pr list          # GitHub
$ gh pr checkout 42
$ glab mr list        # GitLab
$ glab mr checkout 42

Checking out someone's branch is one command, and it is the single most useful thing a reviewer of documentation can do.

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.

  1. Install and sign in to the extension for your platform.
  2. From a branch with a commit, create the merge or pull request from the extension, with a real description.
  3. Open it from the list, and use the extension's checkout action to switch to the branch.
  4. Leave one comment on a line and submit the review as Comment.
  5. 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.

Check yourself

1. What is the main advantage of reviewing in the editor rather than the browser?
2. Which GitLab extension feature needs a token with the api scope?
3. Where is the authoritative list of what is blocking a merge?

Key terms

Merge request (MR) Pull request (PR) Code review Pipeline