Gerrit Code Review

From LSDevLinux
Revision as of 13:31, 14 March 2011 by Mayhewn (talk | contribs) (Categorize)

Jump to: navigation, search

The web interface of our Gerrit installation can be accessed at http://hydra.wycliffe.ca:9160

Setup

Gerrit relies on a Change-Id line in a commit message so that updates to a patch are recognized. This can be created with a git hook. To install the hook, copy it from Gerrit's daemon:

$ scp -p -P 29418 mygerritusername@hydra.wycliffe.ca:hooks/commit-msg .git/hooks/

You have to do this for each project you're working on.

You need to tell Gerrit about your public SSH key if you want to be able to upload changes to Gerrit. Instructions are available here.

Using Gerrit

Uploading changes for review

To upload changes for review:

$ git push ssh://mygerritusername@hydra.wycliffe.ca:29418/projectname HEAD:refs/for/master

You can edit your ~/.ssh/config file and add:

Host gerrit
   Hostname hydra.wycliffe.ca
   Port 29418
   User mygerritusername

Then you can upload changes with:

$ git push gerrit:projectname HEAD:refs/for/master


Using repo

Initializing complete FieldWorks project

$ mkdir fwrepo
$ cd fwrepo
$ repo init -u git://git.lsdev.sil.org/Calgary/WW/manifest.git
$ repo sync
$ cd Calgary/WW
$ git config --add remote.gerrit.fetch +refs/remotes/p4/*:refs/remotes/p4/*
$ git config review."hydra.wycliffe.ca:9160".username mygerritusername
$ git fetch gerrit
$ cd .git/hooks
$ ln -s ../../../../manifests/pre-rebase .

Starting work in a topic branch

$ repo start BRANCHNAME --all

Sending changes for review to Gerrit

$ repo upload

Administrative tasks

Creating a new project

$ ssh -p 29418 mygerritusername@hydra.wycliffe.ca gerrit create-project --name new/project --description "'description for new project'"

Then import the existing code base into Gerrit's git repo:

$ git push ssh://mygerritusername@hydra.wycliffe.ca:29418/new/project HEAD:refs/heads/master

You might have to edit the access rights for the project in Gerrit and temporarily add Forge Identity:+3 for your user/group.