Code Matters - �Eclipse Hackers Git Guide
EclipseCon 2014
http://eclipse.org/jgit
http://eclipse.org/egit
http://code.google.com/p/gerrit
Stefan Lay�(SAP)
Lars Vogel
(vogella)
Christian Grail�(SAP)
Gerrit Code Review @ Eclipse
https://git.eclipse.org/r/ is activated for most projects
Case study: Contributing to Eclipse
Agenda
Introduction
Exercises
Setup & Cloning the Sample Repository
Local Development with EGit
Gerrit Code Review�Contribution to Eclipse
Q & A
Git
Version Control
Distributed
Created 2005 for Linux Kernel development
Enables collaborative Workflows
Git at Eclipse
2010
2011
2012
2014
EGit and JGit projects used Git and Gerrit
Projects could move to git
Gerrit available for all projects
CVS support ended
2013
Development with Git and Eclipse
Developer PC
Gerrit
git
git
git
git
Developer PC
git
git
clone repository
Sample Application
Git Exercises
1 Setup & Clone the example repository
2 Develop a feature
3 Work on branches in parallel
4 Fetch the latest state
Copyright © S. Lay, M. Sohn
Git in a nutshell
Git Concepts: Storage
Git Concepts: Storage
Git Concepts: Commits
Git Concepts: Commits
Git Concepts: Branches
Git Concepts: Branches
Git Exercises
5 Merging, Rebasing, Resolving Conflicts
6 History view
7 Change a series of commits
8 Git blame
Gerrit code review
Originally developed by Google for code review of the Android OS project
Gerrit Code Review @ Eclipse
https://git.eclipse.org/r/ is activated for most projects
Contributions in Git
I fix Eclipse
Contributions in Git
Integration
repository
Contributor 1
Fetch/ Push
Git
Fetch
I fix Eclipse
Contributions either via patches or commit rights
Fetch/
Push
Reviews
I don't know this guy,
he does not get
commit rights.
Committer
Reviewing patches
Fetch/
Push
Reviews
To much
work… especially if there is a feedback loop
Committer
Rule #1 of good code review - Make it easy!
Reviews must
be easy
Contributions
must be
easy
Roles in a Gerrit project
Review feedback
Integration
repository
Contributor 1
Contributor 2
Reviewer
Fetch/
Push
Fetch
Fetch/ Push
CI Build
Server
Fetch
Gerrit
Reviews
Fetch
Fetch
Approve +1
Suggestion to improve -1
Integration
repository
CI Build
Server
Fetch
Gerrit
Reviews
Approve +2
Committer
Rejects -2
Advantages of Gerrit code review
One Commit == one Gerrit review
Gerrit review is identified via the Change-ID in the commit message
Amend the commit and push the changes to update the review
Dark side of Gerrit
Comparison to Github
Gerrit
Access Control
Gerrit
git push
Git Concepts: Pushing to Gerrit
Demo
Gerrit
Commenting
Gerrit
Discussing & Improving
Copyright © S. Lay, M. Sohn
Gerrit
Voting
Gerrit
Learn more:
Talk by Shawn Pearce (Gerrit founder and Project Lead)�and Ian Bull
Extending Gerrit: A Look at the Gerrit Plugin API
Tuesday, 10:30 to 11:05, Bayside
Gerrit Exercises
1 Configure push to Gerrit
2 Push change to Gerrit
3 Review change
4 Improve a change
5 Submit a change to the codebase
6 New Changescreen
7 View Gerrit review notes
Common
ancestor
Commit 3
origin/master
Gerrit issue #1 – non fast forward change
Commit 4
Gerrit review 2
Gerrit review 3
Commit 2
Commit A
Commit B
origin/master
Solution issue #1 – Rebase
Commit 4
Gerrit review 2
Gerrit review 3
Commit A
Commit B
More...
Commit 1
Commit 2
Commit 3
origin/master
Gerrit issue #2 – Push a series of
unrelated changes
Commit 4
Gerrit review 1
Gerrit review 2
Gerrit review 3
Commit 1
Commit 2
Commit 3
origin/master
Gerrit issue #2 – Push a series of
unrelated changes
Commit 4
NO WAY THIS
GETS INTO OUR
CODE BASE!!!
Gerrit review 2
Gerrit review 3
Commit 1
Commit 2
Commit 3'
origin/master
Gerrit issue #2 – Solution
Commit 4'
git reset --hard origin/master
git cherrypick 4
Push again to Gerrit → new change set
Gerrit review 2
Gerrit review 3
Commit 1
Commit 2
origin/master
Gerrit issue #3 – Using the same Change-ID
in two commits
Commit 3
Change-ID I123
Change-ID I123
Change-ID I123
Commit 1
Commit 2
origin/master
Gerrit issue #3 – Solution: Squash commits
Commit 3
Squash commits
Push again to Gerrit → new change set
Change-ID I123
Change-ID I123
Change-ID I123
Commit 2'
Change-ID I123
Changes from 2 and 3
Gerrit Code Review @ Eclipse
https://git.eclipse.org/r/ is activated for most projects
Case study: Contributing to Eclipse
Q&A
Join us at the
EclipseCon Hackathon
and learn how to hack on JGit / EGit
Harbour - Tuesday, March 18, 2014 - 19:00 to 21:00
Evaluate This Session
Sign-in: www.eclipsecon.org
Select session from schedule
Evaluate:
1
2
3