Published on
Last December I wrote about the effective code review process I started at Outpace. The process works well; participants say it is the most effective review process they've experienced. The rest of this post is a summary of the process with a bit of an enhancement around setting up the code for review. I'd recommend you read the original post for a bit more color on the process.
It's a lightweight process. If you're already using GitHub it doesn't bring in any other tools and, unlike some dedicated code review software I've used, the GitHub pull request interface has good performance.
One complaint about this process is that the code you're reviewing appears as deleted in the pull request. It is a superficial complaint but seeing the entire code base as deleted can feel a bit weird.
For the most recent code review, I figured out how to have all the code appear as added. The snippet below contains the steps and example commands.
# cd to the repository you are reviewing.
cd blog
# Make a new branch.
git checkout -b empty-repo
# Copy all files in repo to a temporary directory.
rm -rf /tmp/repo && mkdir /tmp/repo && cp -R * /tmp/repo
# Remove all files from repository, commit, and push to GitHub.
rm -rf *
git commit -am 'remove all files'
git push origin empty-repo
# Create a new branch with the empty-repo as the parent.
git checkout -b code-review
# Copy back in the files and add the files you want to review.
# Commit and push to GitHub.
cp -R /tmp/repo/* .
git add files-to-review
git commit -m 'adding files for review'
git push origin code-review
# Now, go to project on GitHub and switch to the code-review branch.
# Open a pull request comparing the empty-repo and the code-review
# branch.
Voila, you now have a pull request with every line under review marked as added instead of deleted! It takes a little more than two times the number steps required to open a pull request with the code deleted but you might find it worth it. Seeing code as added instead of removed is a minor thing but minor things can make a process more enjoyable. It is nice to know it is possible.
If you aren't doing code reviews or have found them useless in the past, I recommend you try out this process. This post is the abbreviated version but it gives you enough to get started. If you haven't done one in this style before, I'd highly recommend reading the longer post as it gives some details that I've left out here.