Top Banner
Luca @ gerritforge.com http :// www.gerritforge.com Twitter: @gitenterprise GitHub plugin for Luca Milanesio GerritForge gerri t Gerrit Code Review Platinum Sponsor
31

Gerrit Code Review with GitHub plugin

May 10, 2015

Download

Education

Luca Milanesio

GitHub pull request model and Gerrit Code Review, which one is best for you ?
What are the plus and minuses of both models ?

See how it make sense to use one or the other or even both together.

The GitHub plugin for Gerrit Code Review allows the existing developers community to start exploring code review without loosing contact with the github.com presence.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Gerrit Code Review with GitHub plugin

[email protected]://www.gerritforge.comTwitter: @gitenterprise

GitHub plugin for …

Luca Milanesio

GerritForge

gerritGerrit Code Review

Platinum Sponsor

Page 2: Gerrit Code Review with GitHub plugin

2 .io

About Luca

Luca MilanesioCo-founder of GerritForge

over 20 years of experience in Agile Development SCM and ALM worldwide

Contributor to Jenkins since 2007 (and previously Hudson)

Git SCM mentor for the Enterprise since 2009

Contributor to Gerrit Code Review community since 2011

Page 3: Gerrit Code Review with GitHub plugin

3 .io

About GerritForge

Founded in 2009 in London UKMission: Agile EnterpriseProducts:

Page 4: Gerrit Code Review with GitHub plugin

4 .io

Agenda Fork+Pull request or Change review ? People says … My experience say … Plugging two worlds together echo "github" | sed -e "s/git/gerrit/" Pull requests and Repo replication What do YOU think ?

Page 5: Gerrit Code Review with GitHub plugin

5 .io

Two divided review worlds

BRANCH+

PULL REQUEST

CHECKOUT+

AMEND

Page 6: Gerrit Code Review with GitHub plugin

6 .io

Fork + Pull request

GitHub BitBucket GitLab Gitorious + others …

> 10M repositories > 4M users SourceRepo

mastera1c 2df f9a

fork

masterdec 6fa 7a1

Page 7: Gerrit Code Review with GitHub plugin

7 .io

Change review (rebase example)

Gerrit GitBlit + others?

SourceRepo

mastera1c 2df 7a1

dec 6fa 7a1 changes/27/1627/*

amend amend

Page 8: Gerrit Code Review with GitHub plugin

8 .io

Two worlds at a glance

1. BRANCH

2. SCORE THE

BRANCH

3. MERGE ALL

COMMITs in

BRANCH

1. CHECKOUT

2. SCORE THE

COMMIT

3. MERGE ONLY

the REVIEWED

COMMIT

Page 9: Gerrit Code Review with GitHub plugin

9 .io

WHAT PEOPLE SAY ?

Page 10: Gerrit Code Review with GitHub plugin

10 .io

There are two fundamental problems with single-patch review systems:1. They encourage lumping at-best-weakly-related

changes together.2. They encourage you to hide your history.

[http://bit.ly/1hhQkcA]

The pull-request system looks like an incredible easy way to contribute to any project hosted on Github [but] doing any proper and useful contribution to a software is never done right the first time. But as a software maintainer you'll end up with pull-request you'll never get finished unless you wrap things up yourself.

[http://bit.ly/1o7HIb6]

A big advantage in Github's favor is the number of developers that are familiar with it compared to Gerrit.

Gerrit can be popular with Git power-users, but friction-free use of it requires intermediate or advanced git knowledge, and tolerance of a steep learning curve.

[http://bit.ly/1cJV8IJ]

I have no problem with people using github as a hosting site, but in order for *me* to pull from github, you need to(a) make a real pull request […]: real explanation,

proper email addresses, proper shortlog, and proper diffstat.

(b) since github identities are random, I expect the pull request to be a signed tag

[http://bit.ly/1iONQ4L]

Page 11: Gerrit Code Review with GitHub plugin

11 .io

MY OWN (OpenSource +

Enterprise)

[humble] EXPERIENCE …

Page 12: Gerrit Code Review with GitHub plugin

12 .io

Review modelDO NOT make git bisect + git cherry-pick

uselessDO NOT throw commits over the fence

(e.g. “I’ve made the pull request, now it’s up to you”)

Page 13: Gerrit Code Review with GitHub plugin

13 .io

Governance

DEFINE rules for your projectTRUST your identities and roles

Page 14: Gerrit Code Review with GitHub plugin

14 .io

Social engagement

MAKE your project visible MAKE collaboration easy and fun

Page 15: Gerrit Code Review with GitHub plugin

15 .io

Growth

PLAN for collaboration model to scaleAVOID explosion of forks and pending pull-

requests

Page 16: Gerrit Code Review with GitHub plugin

16 .io

Can we take both worlds ?

+ = ?

Page 17: Gerrit Code Review with GitHub plugin

17 .io

GitHub plugin for Gerrit Code Review

https://gerrit-review.googlesource.com/#/admin/projects/plugins/github

1. Imports Pull Requests Gerrit Changes / Topics2. Reuses GitHub identity using Gerrit auth rules3. Replication: keeps presence on http://github.com 4. Prevents explosion of unmanaged forks 5. Avoid GitHub spamming one-email-per-change

Page 18: Gerrit Code Review with GitHub plugin

18 .io

Gerrit and GitHub? Who is ever gonna use it?

June 2014 Statistics

select count(*) from accounts = 1664 usersselect count(*) from changes = 3654 changesselect count(*) from patch_sets = 4720 patch-setsfind . -name '*.git' | wc –l = 5022 repositoriesdu -s -h git = 140 GBytes

Page 19: Gerrit Code Review with GitHub plugin

19 .io

THIS IS COOL !

How can use it ?

Page 20: Gerrit Code Review with GitHub plugin

20 .io

SPEEDY WAY

http://GerritHub.io/login

Page 22: Gerrit Code Review with GitHub plugin

22 .io

HACKY WAY

Build the plugin from source

Page 23: Gerrit Code Review with GitHub plugin

23 .io

Step#1 - GitHub OAuth 2.0 application keyshttps://github.com/settings/applications/new

Your server URL (hostname / port Gerrit will listen to)

OAuth 2.0 callback URL isYour server URL + /oauth

Page 24: Gerrit Code Review with GitHub plugin

24 .io

Step#2 – Get OAuth Client-Id / CLient-Secret

GitHub OAuth 2.0 credentials for Gerrit integration

Page 25: Gerrit Code Review with GitHub plugin

25 .io

Step#3 – Download Gerrit 2.10 (master)

http://ci.gerritforge.com/job/Gerrit-master

Page 26: Gerrit Code Review with GitHub plugin

26 .io

Step#4 – build GitHub plugin

git clone https://gerrit.googlesource.com/plugins/github && cd github mvn install[…][INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 7.755s[INFO] Finished at: Sat Mar 15 19:16:23 GMT 2014[INFO] Final Memory: 57M/449M[INFO] ------------------------------------------------------------------------

Page 27: Gerrit Code Review with GitHub plugin

27 .io

Step#5 – install OAuth filter and GitHub plugin> export GERRIT_SITE=/var/gerrit

> mkdir –p $GERRIT_SITE/lib > cp github-oauth/target/github-oauth*.jar $GERRIT_SITE/lib

> mkdir –p $GERRIT_SITE/plugins > cp github-plugin/target/github-plugin*.jar $GERRIT_SITE/plugins

Page 28: Gerrit Code Review with GitHub plugin

28 .io

Step#6 – Gerrit setup + replication + singleusergroup> cd $GERRIT_SITE && java –jar release.war init –d $GERRIT_SITE*** Gerrit Code Review 2.9-rc1-779-g90fac34-dirty*** […]*** User Authentication*** Authentication method ? HTTPGet username from custom HTTP header ? YUsername HTTP header ? GITHUB_USER

*** Plugins*** Install plugin singleusergroup version v2.9-rc2-536-g79393b2 [y/N]? yInstall plugin replication version v2.9-rc2-536-g79393b2 [y/N]? y

Page 29: Gerrit Code Review with GitHub plugin

29 .io

Step#7 – Configure GitHub integration

[…]

*** GitHub Integration*** GitHub URL ? https://github.comUse GitHub for Gerrit login ? Y ClientId ? 732819a7b9c9d9a98 ClientSecret ? 6271627a6a7s6s718173642718a9bcacdHTTP Authentication Header [GITHUB_USER]:

Page 30: Gerrit Code Review with GitHub plugin

30 .io

Page 31: Gerrit Code Review with GitHub plugin

Replay presentation: http://slideshare.net/lucamilanesio

Sign-in: http://gerrithub.io/login

Gerrit book: http://gerrithub.io/book

Learn more about

20% OFF Book discount for 33 Degree.org User Conference

Book CODE: dg7jnZ eBook CODE: Wi86Zh