Gerrit overview

Author: Yuriy Taraday
Contact: yorik.sar@gmail.com; ytaraday@mirantis.com

Outline should be:

  • Gerrit's place in the world
  • Gerrit data model and terminology
  • Gerrit change request lifetime
  • Big Workflow picture
  • How to use it with Git only
  • How to use git-review

Gerrit origins

Forked because Guido didn't want to complicate Rietveld code with ACL stuff

Gerrit Rietveld - Dutch architect Guido is fond of

Apache Mina SSH daemon - some claim it's slow, but it looks like it's enough for entire Android community

Common collaboration scheme

images/generic_process.png
Even with distributed VCS, some authoritative repository is used, code review is done using feature branches and commiting to master branch with gate.

Gerrit collaboration scheme

images/gerrit_process.png

Gerrit manages authoritative repo, all changes are first stored in separate area for review and are merged to repo's branches only on successful review.

Developers and CI infrustructure fetch code from that repo.

Gerrit also provides very powerfull access control stuff.

Gerrit data model and terminology

Project
a big manageable piece, actually a single repo controlled by Gerrit
Branch
a branch in that repo that is visible to outer world
Change request
  • can be though of as a branch but it's always a single commit changing
  • Has attributes like "status" (Review, Abandonned, Merged), "owner" (the one who pushed it first)
  • is tied to a specific branch of a specific project
  • change id is generated from commit's tree id, parent commit id, comitter and author
Patchset
  • represents one version of each change, requires constant amending
  • they are tied to change request by change-id in commit message, every new pushed commit becomes new change request otherwise
  • parent commit must be merged into the branch to let the patchset through
Comment
  • anyone with access to the change can just write some comment or a number of inline comments and publish them
  • users with review rights can place their +-1 labels on the current patchset

Change request lifetime

lifetime created Patch set 1 pushed review Everybody take a look created->review abandon Abandonned abandon->review complaint Someone complains review->complaint verified Verify +1 review->verified reviewed Review +1 review->reviewed approved Review +2 review->approved fix Someone fixes fix->review fix->complaint lastdot verified->lastdot reviewed->lastdot approved->lastdot merged Submitted lastdot->merged

It's very simplified.

  • Someone pushes one's code to Gerrit, creates a new change
  • Now change is open for everyone to look at
  • Verifier (can be some Jenkins running unittests or QA engineer) can label it with Verifiy +1 or -1 labels
  • Anyone can give it a Review +1 or -1, these labels are only states of opinion.
  • Approver (core developer, dev manager or smth like that) can give it +2 or -2.
  • Once change (current patchset) gathered Verify +1 and Review +2, it can be submitted to the branch.
  • If someone doesn't like something, one places a "-" label, so that everyone including the author can see that smth is wrong, fix it and push a new patchset.
  • If author gives up on pushing this change, one can abandon it.

Labels: Verified

Labels: Review

Submit requirements

Big workflow picture

images/big_workflow.png

Picture shows workflow used by Android community.

Basically everything's the same as at previous picture, but with more details

How to use it with Git

  • It's better to create a remote for simpler usage
  • Gerrit will create a change request for every commit that is absent in branch and is not tied to any existing patchset.
  • Note that Gerrit will process all parents of HEAD as well
  • To avoid this, always use Change-Id line

Change-Id magic

Review process

Short demo

  • Create a couple of commits
  • push them manually
  • show them in web
  • show diff, inline comments
  • show labels and big comments
  • how labels disapear
  • how they don't
  • finally submit

git-review utility

Problems:

OpenStackers created git-review tool

OpenStack wanted to migrate to Gerrit, but it was too complex

Internally git-review uses gerrit command line interface

git-review: config

You should have .gitconfig file in repo to let every user benefit from git-review

[gerrit]
host=gerrit.example.com
port=29418
project=myopenstack/keystone
defaultremote=gerrit-myopenstak
defaultbranch=longlived-branch

defaultremote allows to use one repo with several Gerrits (internal and upstream)

defaultbranch leaves no place to forget where to push

File should be created/edited by project/branch maintainer.

Merges should not affect it.

defaultbranch is pretty recent

git-review: workflow

Conclusion

The end

Thanks!

Slides are at http://yoriksar.github.com/gerrit-slides/