Reviewboard post-commit hacking

Introduction

First and foremost i would like to share in this page my knowledge with a code review tool Review Board. This tool gained much friction when VMWare released it as a FOSS software. I’ve been looking at it for some time. Lastly I have finally found some time for proper configuration of this tool.

Background

I work in a company with a small team of software developers. In this situation and with the business rules in our company we have to develop software in a quick timeframe. Because of that there is no time for code review in slow pace. Basically there is not enough developers and time (sic!) for code review meeting etc. Because of that i was looking for a tool, which can help us review code in a more comfortable way and tightly connected with the code development methodology.

Tool

The ReviewBoard (RB) application is quite fun to use. Basic way of using RB is to perform so called pre-commit review. That is a developer create a patch from his uncommited code and submit it to the RB tool. Reviewer are inspecting a code and when everything is just right the developer commit the code to the repository.

In my situation i would like to review a code already commited to repository. It’s faster and it does not impose serious security flaw to the main code. This operation mode is called post-commit operation. It is briefly described on the RB site here. Unfortunately the script provided in the contrib directory of RB installation does not provide a mean for my case. It is useful for closing review requests by analyzing commit logs. In my case i would like to create review request directly from a commit log (and attached patch). There is a script attached to a code review request on main RB site – the script is located here.

Execution

I will explain steps needed to perform post-commit operation in my case (YMMV).

  • install RBTool on the repository server
$ easy_install -U RBTools
  • add your reviewboard server location to the repository (working copy) in the trunk directory
$ svn propset reviewboard:url http://rs.yourserver.com
  • get script from here and save it eg. in the /usr/local/bin directory. I renamed it to commit-reviewboard.py name
  • create post-commit script in the hooks directory of the subversion repository (real repository on the server)
#!/bin/bash
#
REPOS="$1"
REV="$2"
export HOME=/var/www
/usr/bin/python /usr/local/bin/commit-reviewboard.py "$REPOS" "$REV" || exit 1. 
  • Note that i’ve set the HOME direcotry from that script. In my environment the variables (eg. HOME) has not been set and there was an error trying to create cookies file from the RBTools’ post-review script
  • That’s all, Start using it

Usage

When commiting a new code and when you would like to create code review request you have to commit a log message with text “Publish review”. When this text appear post-commit scripts will create review request. More usage information can be found in the script itself.

Have Fun using it!