Ask HN: How do you review code?
We use Gerrit. Gerrit is a review system derived from the Git technology.<p>From the Git user&#x27;s point of view, Gerrit is installed as a git remote. When you develop some changes, you push them to the Gerrit remote, using a special branch naming convention. Gerrit dynamically takes this push and converts it to a review item, which is then subject to a web-UI-with-email-notifications-based review workflow.<p>A special &quot;Change-ID:&quot; item in the commit header identifies the change. This lets you push revised versions of the commit: if the Change-ID matches, Gerrit recognizes a push as being the new version of a previous push. These versions are organized in the review process under one item. You can see what the differences are between different versions and so on.<p>The review process involves multiple users in reviewer roles. They get notified via an e-mail that there is something for review. Then they can look at the changes, and approve or reject the commit. General comments can be added to the item and comments can be attached to individual lines of code, also, so you can easily say very specific things about specific pieces of code.<p>We have automatic reviewers who participate also. For instance, if a kernel change is proposed, then &quot;checkpatch&quot; is run on it automatically, and posts an approval or disapproval to the Gerrit item. The code also has to build for several targets and pass automatic smoke tests.<p>Commits are ultimately merged by users who have the power to do that. They take into account all the other votes and then cherry pick the change.<p>Gerrit is far from perfect, but it provides a decent workflow, and is a huge improvement over <i>ad hoc</i> development.  For instance, the Change-ID can be a pain. It&#x27;s assigned by Gerrit when you first push something, and then you must remember to add that same Change-ID to the new version of the commit. I wrote myself a script which generates a Change-ID; I stick it into the very first commit, so Gerrit doesn&#x27;t have to make one up for me.<p>To use Gerrit, users have to acquire a somewhat better than average understanding of git; it&#x27;s just a little bit more advanced than the &quot;pull, commit and forget&quot; use cases whereby you pretend that git is SVN or CVS.
Things should be set up to prevent common mistakes; for instance, lock the repository from direct pushes, so only pushes to Gerrit are allowed. I would make a blank &quot;Change-ID:&quot; part of the commit message template, and give users a way to generate these things, to avoid the common mistake of pushing a new version of a commit without a Change-ID, causing Gerrit to generate a whole new review item.