title: 'RBTools example: How do easily do code reviews with Review Board and post-review' author: admin type: post date: 2014-07-17T18:57:27+00:00 url: /rbtools-example-how-do-easily-do-code-reviews-with-review-board/ sf_thumbnail_type:
Note: This script has been merged into Hue as 'tools/script/hue-review'.
Here is a tutorial about how to use the code review tool Review Board for a better productivity!
First, join the 'hue' group in your account https://review.cloudera.org/account/preferences/!
Then install the Review Board tools:
sudo pip install -allow-all-external RBTools
Point it to your git repository:
romain@runreal:~/projects/hue$ rbt setup-repo
Enter the Review Board server URL: https://review.cloudera.org
Use the Git repository 'hue' (git://github.com/cloudera/hue.git)? [Yes/No]: yes
Create '/home/romain/projects/hue/.reviewboardrc' with the following?
REVIEWBOARD_URL = "https://review.cloudera.org"
REPOSITORY = "hue"
BRANCH = "master"
Config written to /home/romain/projects/hue/.reviewboardrc
We have wrapped up the typical submission in a dedicated 'tools/scripts/hue-review' script prefilled with all the details of the commits:
vim tools/scripts/hue-review
function hue-review {
#!/usr/bin/env bash
if [ $# -lt 3 ]; then
echo "Usage: hue-review rev-list reviewer(s) summary ..." 1>&2
exit 1
fi
RBT=\`which rbt\`
if [ "$?" -ne "0" ]; then
echo "Please install rbt from https://www.reviewboard.org/" 1&>2
exit 1
fi
REVLIST=$1;
REVRANGE=${REVLIST//\.\./:};
REVIEWER=$2;
SUMMARY=$3;
shift 3;
exec $RBT post -o -description="$(git whatchanged $REVLIST)" -target-groups=hue -target-people="$REVIEWER" -summary="$SUMMARY" $REVLIST $@
}
If you use a Mac:
#!/usr/bin/env bash
if [ $# -lt 3 ]; then
echo "Usage: hue-review rev-list reviewer(s) summary ..." 1>&2
exit 1
fi
RBT=\`which rbt\`
if [ "$?" -ne "0" ]; then
echo "Please install rbt from https://www.reviewboard.org/" 1>&2
exit 1
fi
REVLIST=$1;
REVRANGE=${REVLIST//\.\./:};
REVIEWER=$2;
SUMMARY=$3;
shift 3;
exec $RBT post \
-o \
-description="$(git whatchanged $REVLIST)" \
-target-groups=hue \
-target-people="$REVIEWER" \
-summary="$SUMMARY" \
$@ \
$REVLIST
Then:
source /home/romain/.bashrc
or put it in your PATH.
Now we post the review:
tools/scripts/hue-review HEAD~1..HEAD romain,enricoberti,erickt "HUE-2123 [beeswax] Handle cancel state properly" -bugs-closed=HUE-2123
Review request #4501 posted.
https://review.cloudera.org/r/4501/
Et voila! Here is our review https://review.cloudera.org/r/4501/.
Note:
If you have more than one diff, update HEAD~1..HEAD accordingly (e.g. HEAD~2..HEAD)
Modify the previous commit diff:
git commit -a -amend
... Update a file ...
[master 9c7c7af] HUE-2123 [beeswax] Handle cancel state properly
3 files changed, 10 insertions(+), 4 deletions(-)
Update the review:
rbt post -u -r 6092 HEAD~1..HEAD
Review request #6092 posted.
We hope that Review Board and these commands will make your life easier and encourage you to contribute to Hue 😉
As usual feel free to send feedback on the hue-user list or @gethue!