Just a quick tip for developers working on OpenStack projects that work on multiple development machines or want to pull a colleague’s code from the Gerrit review system and test it locally.
If you have followed the instructions about setting up a development environment successfully, you will have installed the git-review tool that Jim Blair and Monty Taylor maintain. The git-review tool has a nice little feature that enables you to easily pull any branch that anyone has pushed up to code review:
$> git review -d $REVIEW_NUM
The $REVIEW_NUM
variable should be replaced with the identifier of the review branch in Gerrit.
For example, I developed some code on my laptop that I now want to pull to my beefier work machine. The original branch is failing a few tests in Jenkins and I want to diagnose what’s going on. The review branch is here: https://review.openstack.org/#change,1656. The review number (ID) is 1656.
To grab that branch into my local environment and check it out, I do:
jpipes@uberbox:~/repos/glance$ git review -d 1656 Downloading refs/changes/56/1656/2 from gerrit into review/jay_pipes/bug/850377
Doing a git status, you’ll note that I am now in the local branch called review/jay_pipes/bug/850377:
jpipes@uberbox:~/repos/glance$ git status # On branch review/jay_pipes/bug/850377 # Your branch and 'gerrit/master' have diverged, # and have 1 and 2 different commit(s) each, respectively. # nothing to commit (working directory clean)
I can now run tests, diagnose the issue(s), fix code up and do a:
$> git commit -a --amend $> git review
And my changes will be pushed up to the original review in Gerrit for others to look at.