Transcript of "Using Gerrit Code Review in an Open Source Project"
Brussels, 02. - 03.02.2013 1Using Gerrit Code Review in an Open Source Project License: CC BY-SA 3.0 (pictures of other authors excluded)
Brussels, 02. - 03.02.2013Contents of this talk 2 • Gerrit is a • Web-based code review tool • Git server • Using Gerrit in the TYPO3 project • Large PHP community • Experience of the last 2.5 years
Brussels, 02. - 03.02.2013 Steffen Gebert 3 • TYPO3 CMS Core Team Member (2010-2012) • TYPO3 Server Admin Team Member (since 2011) • PhD Student in Computer Science (Communication Networks, since 2011) • E-Mail: firstname.lastname@example.org Twitter: @StGebertI’m not affiliated with Gerrit or Google. Just a happy user (and contributor of 4 tiny patches)
Brussels, 02. - 03.02.2013 Questions! 4 • Happy to answer your questions! • Come down here after the talk! comments included! • Slides availableFoto “Question mark”: Yello-Doghttp://www.sxc.hu/photo/1279316 http://slideshare.net/stephenking/nice that you found the slides - have fun ☺
Brussels, 02. - 03.02.2013 Motivation for Code Reviews 5 • Who writes bug-free code? • Who knows all best-practices of programming? • Review changes of friends and contributors! • Keep bad code out of your repository Example Policy: • Learn from others “Every ch ange has be review to ed by at least two other persons”Based on a photo by CMSeterhttp://www.sxc.hu/photo/1062451With Gerrit you can actually enforce these policies, also for team members.
Brussels, 02. - 03.02.2013 Gerrit: Web-based Code Review 7 • 1 Commit 1 ChangeThat’s the list of open changes for all projects. One change her refers to one commit that isreviewed.
Brussels, 02. - 03.02.2013 Gerrit: Web-based Code Review 8 • Change Details Screen commit message change meta data reviewsThe Change-Id is a very interesting thing. Due to the time constraints, I’m not able to tell thewhole truth in the talk itself - so here’s the explanation:If you want to have Patch Set 1 and Patch Set 2 to appear in the same change request inGerrit, you need that Change-Id to stay the same for all versions of the commit (differentversions created through `git commit --amend`.Every contributor needs the commit-msg hook in his Git repo, before the commit is made.This auto-generates the Change-Id and adds it to the commit message. See http://gerrit-documentation.googlecode.com/svn/Documentation/2.5/cmd-hook-commit-msg.html
Brussels, 02. - 03.02.2013 Gerrit: Web-based Code Review 9 • Commit Details patch set history get changes open diff views add your review changed filesDifferent versions of the same commit are grouped in one change request. You can comparedifferent patch set versions. That’s nice :)
Brussels, 02. - 03.02.2013 Review Workﬂow 11 Graphics by Chris Aniszczyk Thanks! git push origin HEAD:refs/for/mastergit commit --amend enough votes collectedthe “enough votes collected” state can be deﬁned by Prolog Submit rules. One can’t submit achange, if there aren’t enough positive reviews.
Brussels, 02. - 03.02.2013 Gerrit as Git Server 12 • Full-featured¹ Git server functionality, based on JGit • Smart HTTP and SSH access to repos • Gitweb integration, Gitblit integration under development • Fine-grained access control settings • Per-branch • Push commits from different author/committer • Allow merges, forced push, branch deletion • ... ¹As JGit has only experimental garbage collection, you should run `git gc` manually from time to timeThe Git protocol is not supported by Gerrit itself. However, using built-in replication to thesame/another host running a Git daemon is pretty common and easy.Access control settings are on a per-branch level. So one group might be allowed to pushdirectly to branch A, but not to B
Brussels, 02. - 03.02.2013 Example Access Control Settings 13 Group Permissions via Git Permissions via Web UI rights inherited top to bottom Anonymous Clone Repo Browse Changes Registered Users Push for Review Review (Comment, +1 Vote) Team Members Review (+2 Vote), Submit Team Leaders Create Branches + Tags Abandon Changes, Manage Team into No reviews required? (use as normal Git server) repo Team Members PushUsually, you don’t want anybody to bypass review. In doubt, one can self-approve his ownchange, if it’s trivial.It’s perfectly ﬁne to use Gerrit also as a “normal” Git server by allowing committers to pushdirectly to master.
Brussels, 02. - 03.02.2013 More Goodies 14 • Mylyn connector for eclipse • Authentication • OpenID, LDAP, Apache External Auth • Patches for custom auth pending • Prolog submit rules • Stabilized Development • Lead by Google staff • ~10 committers from different companies (Google, SAP, Sony Mobile, Codeaurora, ..)Using an Apache as proxy in front of Gerrit (pretty common) and by using Apache’s ExternalAuth, you can basically authenticate against everything. You can ﬁnd our conﬁg here:https://gist.github.com/4531841Prolog rules allow you to deﬁne conditions, which lead to a change getting approved (= to besubmittable). You can e.g. require votes by three persons, while none of them is the author ofthe patch. AFAIK also possible on a per-branch level. Haven’t looked into that too deep, butsee here: https://gerrit-review.googlesource.com/Documentation/prolog-cookbook.html
Brussels, 02. - 03.02.2013 Gerrit Users 15 • Open Source projects, public gerrit-review. android-review.googlesource.com googlesource.com git.eclipse.org/r/ gerrit.libreofﬁce.org review.openstack.org gerrit.wikimedia.org • Commercial, non-public • SAP, Sony Mobile, Intel, Qualcomm, eBay, Garmin, QT, Ericsson, nVidia, Red Hat, LibreOfﬁce, ... Source and more users: http://en.wikipedia.org/wiki/Gerrit_(software)What might look a bit scary at the ﬁrst moment (compared to Github) is actually pretty nice -and used by several other projects, too!
Brussels, 02. - 03.02.2013 16Gerrit in the TYPO3 project plus m perso y nal opinio n
Brussels, 02. - 03.02.2013What’s TYPO3? 17 • TYPO3 CMS • Started: 1997, ﬁrst release: 1999 • More than 5M downloads • PHP-based, GPLv2 • New products • TYPO3 Flow: PHP framework • “TYPO3 Flow and the Joy of Development” by Robert Lemke from yesterday • TYPO3 Neos • New CMS based on TYPO3 Flow - alpha state
Brussels, 02. - 03.02.2013Development of TYPO3 18 • Development steered through Core Teams (10-25 people) • Mailing list used for Reviews in 2005-2011 • Patches and +1/-1 sent via mail • Big changes were a PITA • Reviews are not new to TYPO3 • Replaced by Git and Gerrit
Brussels, 02. - 03.02.2013 Gerrit at TYPO3 (review.typo3.org) 19 • TYPO3 Flow in 08/2010 • TYPO3 CMS in 03/2011 • 10.669 commits with SVN • 4300+ commits with GitCommits counter over all branches (in master branch only there are 2600+ with git and 7022with svn)
Brussels, 02. - 03.02.2013 More Statistics 20 • 190 projects (ofﬁcial Git support still not announced) • 17.7k changes, 31.6k patch sets, 14.4k comments • 400 people commenting • 291 unique uploaders (5 guys with > 1000 patch sets, 55 with > 100 patch sets) • biggest project: 5100+ changes (TYPO3 CMS Core) • patch sets per change • 155 changes with 10+ patch sets • biggest with 35 patch setsStats taken 27.01.2013
Brussels, 02. - 03.02.2013 Implemented Workﬂow 21 • New patch set uploaded • Humans are notiﬁed via Email • Jenkins is triggered and executes code sniffs • Issue tracker (Redmine) is updated • Change merged • TravisCI executes unit tests • Issue closed • packagist.org notiﬁed for composer packages • Documentation rendering triggered • Under development • TravisCI for every patch setHooks available!We are using the populer “Gerrit Trigger” plugin: https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+TriggerRedmine and packagist.org are updated via Gerrit hooksTravisCI (http://travis-ci.org) relies on Github. So we’re replicating to Github and let Travisgrab it from there.To run TravisCI during review, we’re currently testing the following process:- Fork TYPO3v4-Core repo, apply changes, create a pull request- Travis will pick this one, execute tests and give feedback into the pull request- Read Travis’ vote from Github and add it as voting to GerritContact me or Andy Grunwald <email@example.com> for details
Brussels, 02. - 03.02.2013Personal Comment 22 • Brings quality and transparency into your (open source) project • Easy to improve other’s work - strive for perfect code! • Mature and very stable software, very active maintainers • Well documented • Integration into infrastructure costs severe amount of work • Beginner’s barrier exists. Provide instructions! (see wiki.typo3.org/Git) • Some people say it’s impersonal (but avatar support upcoming) Photo by stylesr1 http://www.sxc.hu/photo/605324
Brussels, 02. - 03.02.2013 23 • Happy to receive your questions! • @StGebert on Twitter • firstname.lastname@example.org • Slides availableFoto “Question mark”: Yello-Doghttp://www.sxc.hu/photo/1279316 http://slideshare.net/stephenking/
inspiring people to share inspiring people to share