Top Banner
Using Git in Eclipse http://eclipse.org/egit Matthias Sohn (SAP) [email protected] + = Chris Aniszczyk (Red Hat) [email protected]
34

Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Nov 11, 2014

Download

Technology

msohn

 
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: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Using Git in Eclipsehttp://eclipse.org/egit

Matthias Sohn (SAP)[email protected]

+ =Chris Aniszczyk (Red Hat)[email protected]

Page 2: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Learning Git – There's no free lunch!

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

… the purpose of this presentation isn't to teach you Git, you have to do that yourself!

Page 3: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git Resources

http://git-scm.com/documentation is your friend

Watch Linus' talk at Googlehttp://www.youtube.com/watch?v=4XpnKHJAok8

Read the Pro Git book - http://progit.org/book/

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 4: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git, EGit and JGit

- Demo and Tour of EGit

Code Review at Eclipse

Gerrit

- Demo of Gerrit

Conclusion

Outline

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 5: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git… a distributed revision control system built by the Linux project to automate patch workflow

Distributed means no central repository•No central authority!•Easy offline usage•Easy to fork a project•Protected against manipulation by cryptographic hashes

Really good at merging•Coordination only needed "after the fact”•Easier to rejoin (or refresh) forked projects

Structured around commits (i.e. patches)•Integrates with email channel•Tools for identifying problem commits (git bisect)•Tools for restructuring branches w/ specific commits

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 6: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Projects using Git

… Git is widely used and is the most popular distributed version control system

GitLinuxPerlGnomeQtRuby on RailsAndroidPostgreSQLWineFedoraDebianX.org and so on...

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 7: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git at Eclipse

Eclipse defined a roadmap to move to Git in 2009CVS is deprecated; SVN will be deprecated in the future

EGit is an Eclipse Team provider for Git http://www.eclipse.org/egit/

JGit is a lightweight Java library implementing Git http://www.eclipse.org/jgit/

The goal is to build an Eclipse community around Git EGit and JGit are still beta and we want to establish a feedback loop to improve the tooling

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 8: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git at Eclipse

EGit and JGit developed at http://egit.eclipse.org

http://git.eclipse.org/ hosts live Eclipse Git reposVirgo, Mylyn Review, ECF, SWTBot …

http://dev.eclipse.org/git/index.html git mirrors for CVSRead-only copies kept up-to-dateCan clone with git:// or http://

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 9: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

History of JGit and EGit2005 Linus Torvalds starts Git

2006 Shawn Pearce starts JGit

2009 Eclipse decides for Git Roadmap JGit/EGit move to eclipse.org SAP joins JGit/EGit

3/2010 Released 0.7 (first release at Eclipse) Diff/Merge Algorithms, Automatic IP Logs

6/2010 Released 0.8 (Helios) Usability Improvements, Git Repositories View, Tagging

9/2010 Released 0.9 (Helios SR1) Merge, Synchronize View, .gitignore

Planned: 12/2010 0.10 (Helios SR2) 3/2011 0.11 6/2011 1.0 (Indigo)

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 10: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Features EGit 0.10

git-add git-format-patch git-shortlog git-relink git-rev-parse

git-am git-gc git-show git-remote git-show-branch

git-archive git-grep git-stash git-repack git-verify-tag

git-bisect git-init git-status git-replace git-whatchanged

git-branch git-log git-submodule git-annotate

git-bundle * git-merge * git-tag * git-blame .gitignore

git-checkout git-mv git-config git-cherry git daemon

git-cherry-pick git-notes git-fast-export git-count-objects Visual merge tool

git-clean  git-pull git-fast-import git-difftool ** HTTP support

git-clone git-push git-filter-branch git-fsck * Mylyn integration

git-commit ** git-rebase git-mergetool git-get-tar-commit-id * Staging View

git-describe git-reset git-pack-refs git-help * Synchronize View

git-diff git-revert git-prune git-merge-tree History View

git-fetch git-rm git-reflog git-rerere Repositories View

** planned for 0.10, * planned for 0.11 supported, partial, missing, irrelevant for EGit

Page 11: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Demo: A tour of EGit

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 12: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git, EGit and JGit

Code Review and Eclipse

Gerrit

Conclusion

Outline

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 13: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

What is Peer Code Review?

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

Often an integral part of coding process

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

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 14: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Code Review – Benefits

Four eyes catch more bugs Catch bugs early to save hours of debugging

Enforce coding standards Keep overall readability & code quality high

Mentoring of new developers Learn from mistakes without breaking stuff

Establish trust relationships Prepare for more delegation

Good alternative to pair programming asynchronous and across locations

Guido van Rossum [1]

[1] http://code.google.com/p/rietveld/downloads/detail?name=Mondrian2006.pdf

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 15: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Code Review at

Eclipse ?

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 16: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Eclipse - Roles

CommitterFormally electedCan commit own changes without review

ContributorSmall changes

reviewed by committersBigger changes

also formal IP review by legal teamin separate protected Bugzilla (IPZilla)

Review Toolpatches attached to bug in Bugzillacomments in Bugzilla

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 17: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Code Review via Bugzilla

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 18: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Eclipse – Review Process

Contributors • create patch using CVS, SVN, Git (since 2009)

• attach patch to bug in Bugzilla

Committers • do code and IP review• comment, vote in Bugzilla• create CQ for changes needing IP review• commit accepted changes

IP Team• does IP review bigger changes from contributors

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 19: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Eclipse – Review Process

Review not done for all changes

Each Eclipse.org project does it differently

Review tedious for contributors (and also for committers mentoring contributors)

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 20: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git, EGit and JGit

Code Review and Eclipse

Gerrit

Conclusion

Outline

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 21: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Gerrit Code Review

Gerrit is a Code Review system based on JGit http://code.google.com/p/gerrit/

Also serves as a git server adding access control and workflow

Used by • Android https://review.source.android.com/• JGit, EGit http://egit.eclipse.org/r/• Google, SAP, …

Eclipse wants to use it …

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 22: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

History Gerrit Code Review

Gerrit: 4th Generation code review at Google

Google started code review with a Linux like review process

• patch based• tooling based on Perforce CLI

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 23: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Google - Web based code review tools

Mondrian (Guido van Rossum)• based on Perforce, Google infrastructure• Google proprietary

Rietvield (Guido van Rossum)• based on Subversion• Open Source hosted on GoogleApp Engine

Gerrit (Shawn Pearce)• started as a fork of Rietvield• based on JGit and GWT• Open Source (Android)• Apache 2 license

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 24: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

One Branch per Feature

Master branch contains only reviewed and approved changes• master moves from good to beter state afer each

(approved) change

Each feature branch is based on the Master branch• stable startng point

A change can really be abandoned because• no other approved change can depend on a not yet

approved change• Gerrit will automatcally reject a successor change of an

abandoned change

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 25: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Gerrit – Lifecycle of a Change

a

master

topic

1

• create local topic branch• commit change• push it for review• do review• automated verification

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 26: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Gerrit – Lifecycle of a Change

c

b

a1

2

mastertopic

3

a

master

topic

1

• create local topic branch• commit change• push it for review• do review• automated verification

• refine based on review• push new patchsets until review votes ok

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 27: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Gerrit – Lifecycle of a Change

c

b

a1

2

mastertopic

3

a

master

topic

1

• create local topic branch• commit change• push it for review• do review• automated verification

• refine based on review• push new patchsets until review votes ok

c

b

a1

2

master

topic

3

d

• Submit may lead to server-side merge• or merge / rebase before push

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 28: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Gerrit Workflow

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 29: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Gerrit

http://egit.eclipse.org/r/ - change,825Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 30: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Code Review – Our Experience

Review all changes!

Review takes time (1 day … weeks)

Implies parallel workflow

Every team member should do reviews regularly

Authors have to wait for the review to happen

Git & Gerrit help a lot here

Code Review | © 2010 by M. Sohn

Page 31: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Gerrit Code Review - Outlook

Upcoming proposal for Mylyn Gerrit Connector

Port from SQL DB to Cassandra

Store review comments as git notes for offline review

Support for change dependencies across repositories

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 32: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Demo: Code Review with Gerrit

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 33: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Git, EGit and JGit

Code Review and Eclipse

Gerrit

Conclusion

Outline

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn

Page 34: Using Git in Eclipse - Eclipse Summit Europe 2010-11-03

Conclusion

EGit and JGit are evolving quickly

Gerrit enables a nice code review workflow

Git supports convenient branching and merging

Git is very fast and scales well

Eclipse and major other OS projects are moving to Git

Git and Gerrit kick ass!

Using Git in Eclipse | © 2010 by C. Aniszczyk and M. Sohn