Using Xcode to review big a pull request

Large pull requests (PRs) are not great and we should always strive for smaller PRs. The reality of working with a large code base, where a small change can affect lots of areas, mean large, many lined PRs are often unavoidable. *

GitHub offers a very good desktop web app for reviewing pull requests. For small and medium sized review this is often good enough. For larger reviews I prefer to these tools with Xcode.

How to use Xcode for large pull requests

For this worked example the PR is from a branch v_big into develop.

1. Get all file changes

From the command line, checkout the PR branch and do a soft reset on top of the branch being merged into.

git checkout v_big  
git reset --soft <git commit hash>  

Where the hash value is the git commit the PR will merge into.

2. Show in Xcode

Open the project using Xcode. Open the Project Navigator (⌘+1) and then apply the Show only modified files filter at the bottom of the navigator pane - see red arrow.

Xcode showing changed files

In the Project Navigator we can see all the files that have changed in this PR.

If you switch to use the Version Editor (⇧ + ⎇ + ⌘ + Return) we can see all the changes.

Now you can move around between the modified files and getting a clearer picture of the changes.

Of course don't forget to leave comments

Benefits

The benefits of this approach mean that the reviewer can navigator around the changes, using action like Jump to... to inspect what new changes have been made.

Often a project is structure to represent a directory-file system - with grouping of similar code or functionalities. Using this Xcode view, the reviewer can see where cluster of changes have occurred as well as being able to quickly choose the critical areas to focus on - while ignoring others.

Another reason I prefer this approach from Github, is that I'm now reviewing in my most natural environment with my familiar styling and shortcuts - which helps focus the mind.

Enjoy.


* Of course if a small change results in many file changes, this a massive red flag that the code base is far too interconnected. A refactoring to decouple structures would be the next thing you do.