eclipse hacker's guide to the git universe
DESCRIPTION
Slides for Git Tutorial held at EclipseCon Europe 2011-11-02 in LudwigsburgTRANSCRIPT
Eclipse Hacker’sGuide to the Git Universe
Tutorial EclipseCon 2011
http://eclipse.org/jgithttp://eclipse.org/egit
http://code.google.com/p/gerrit
Matthias Sohn(SAP)
Stefan Lay(SAP)
Chris Aniszczyk(Twitter)
Kevin Sawicki(GitHub)
Benjamin Muskalla (Tasktop)
Sasa Zivkov(SAP)
background photo courtesy of NASA http://www.nasa.gov/multimedia/guidelines/index.html
Agenda
Introduction
Setup and Cloning the Sample RepositoryLocal Development with EGit
Gerrit Code ReviewMylyn IntegrationGitHub Eclipse Support
Q & A
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Git… a distributed revision control system built by the Linux project to facilitate code review
Distributed means no central repository• No central authority!• Easy offline usage• Easy to branch a project• Protected against manipulation by cryptographic hashes
Really good at merging• Coordination only needed "after the fact”• Easier to rejoin (or refresh) branches
Structured around commits (i.e. patches)• Tools for identifying problem commits (git bisect)• Tools for restructuring branches w/ specific commits
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Git at Eclipse
JGit is a lightweight Java library implementing Git • http://www.eclipse.org/jgit/
EGit is an Eclipse Team provider for Git based on JGit• http://www.eclipse.org/egit/
Gerrit Code Review is a Git server based on JGit adding permission control and review workflow• http://code.google.com/p/gerrit• Denis is on the way to setup Gerrit@Eclipse :-)
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Git at Eclipse
Eclipse is moving to GitCVS has been deprecated and will be retired 2012-12-21
project / code repository break down as of 2011-10-31
http://eclipse.org/projects/scmcountdown.php
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Modern Code Review – What is it ?• When one developer writes code, another developer
is asked to review that code
• A careful line-by-line critique
• Happens in a non-threatening context
• Goal is cooperation, not fault-finding
• Integral part of coding process
• Otherwise this will happen:• Debugging someone else's broken code• – Involuntary code review: Not so good; emotions may flare
Guido van Rossum [1]
[1] http://code.google.com/p/rietveld/downloads/detail?name=Mondrian2006.pdf
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Code Review – Benefits
• Four eyes catch more bugso Catch bugs early to save hours of debugging
• Mentoring of new developers / contributorso Learn from mistakes without breaking stuff
• Establish trust relationships o Prepare for more delegation
• Good alternative to pair programmingo asynchronous and across locations
• Coding standardso Keep overall readability & code quality high
Guido van Rossum [1]
[1] http://code.google.com/p/rietveld/downloads/detail?name=Mondrian2006.pdf
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Developer PC
Gerrit
git gitgitgit
Developer PC
gitgit
Hudson
- clone repository - fetch / push changes
- verify proposed changes- continuous integration builds
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Developer PC
gitgit
Gerrit
git gitgitgit
push improved change 10
Developer PC
gitgit
fetch change 23 to try it
master
change 12
change 10
change 23
submit accepted change 12
fetch master to get updates
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Exercises 1 Setup and Cloning Sample Repository
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Local Development with EGit
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Exercises: Local Development with EGit 2 Develop a feature/bug fix 3 Work on branches in parallel 4 Merge, Rebase, Resolve Conflicts 5 Change a series of commits
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Gerrit Code Review
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Gerrit Architecture
Gerrit = Git server + Access Permissions + Web UI
• Git based code review system• Hosts many Git repositories• Speaks Git protocol
o no Gerrit client installation required• Provides per-project Access Permissions• Web interface for Code Review
o implemented using GWT
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
When does Code Review Happen?
• Code Review happens before changes reach the code base
• Buggy changes discovered and fixed before the change gets merged
• Only completed changes reach the project historyo reviewers reject unfinished changes
• Only well described changes reach the code baseo commit message is also subject of the
review
• Project history clean and usableCopyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Integration with EGit
• Since Gerrit is a Git (server) any Git implementation can work with Gerrit
• However, EGit provides some extra features to make work with Gerrit more comfortableo fetching a change from Gerrit based on its IDo automatic "push to Gerrit" configuration when
cloning a Git repo from Gerrit
• Mylyn Reviews has a Gerrit connector (see next part)
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Exercises: Gerrit Code Review 6.1 Push a Change to Gerrit 6.2 Review a Change 6.3 Improve a Change 6.4 Submit a Change to the Codebase
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Mylyn Integration
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
90% Irrelevant
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Task-focused IDE
< Demo >
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Exercises: Mylyn Integration 7.1 Mylyn / EGit Integration 7.2 Use Gerrit from within the IDE
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
GitHub Eclipse Support
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
GitHub Eclipse Support
• https://github.com/eclipseo 176 mirrored repositories
• Browsing source code• Comparing branches and tags• Activity feeds• Charts & Graphs• Downloading snapshots
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
GitHub Eclipse Support
GitHub EGit Integration
• GitHub Mylyn Connectoro Issueso Gistso Pull Requestso Import Wizard
• GitHub Java APIo Maven pluginso Reportingo Automating tasks
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Exercises: GitHub/Eclipse Integration 8 Setup Share on GitHub
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov
Q&A
Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov