effiziente entwicklungsprozesse mit git, egit und gerrit - intland technology day stuttgart...

59
Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit http ://code.google.com/p/ gerrit http://eclipse.org/egit + = Matthias Sohn (SAP) [email protected] Twitter: @masohn

Upload: msohn

Post on 16-May-2015

2.099 views

Category:

Technology


1 download

DESCRIPTION

Presentation (in german) on efficient development processes with EGit and Gerrit held on Intland Technology Day in Stuttgart on 2011/06/08

TRANSCRIPT

Page 1: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit

http://code.google.com/p/gerrithttp://eclipse.org/egit

+ =Matthias Sohn (SAP)[email protected]: @masohn

Page 2: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Agenda

Git – ein verteiltes Versionierungssystem

Code Review mit Gerrit

Demo: Entwicklung mit Gerrit Code Review neue Features in EGit

Q & A  

Page 3: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, SAP AG

Die Hauptdarsteller

Git ist ein verteiltes Versionierungssystem

EGit ist ein Eclipse Team Provider für Githttp://www.eclipse.org/egit/

JGit ist eine leichtgewichtige Java-Bibliothek für Git http://www.eclipse.org/jgit/

Gerrit ist ein Code-Review-System, basierend auf JGit http://code.google.com/p/gerrit/

Page 4: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, SAP AG

Geschichte von Git, JGit und EGit2005    Linus Torvalds initiiert Git

2006    Shawn Pearce initiiert JGit

2009    Eclipse entscheidet sich für Git JGit/EGit ziehen um nach eclipse.org

SAP beteiligt sich JGit/EGit-Projekte benutzen Gerrit

 3/2010 JGit/EGit Release 0.7 (erstes Release bei Eclipse)  6/2010 Release 0.8 (Helios) 9/2010 Release 0.9 (Helios SR1)

2010/11 Releases 0.10 – 0.12            3/2011 Eclipse Community Award: Most Innovative new feature

6/2011 Release 1.0 (Eclipse Indigo)

Page 5: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Jeder Entwickler besitzt ein komplettes Repository

Verteilte Versionierungssysteme (DVCS):Git, Mercurial, Bazaar, …

Git: 2005 für die Linux-Kernel-Entwicklung

Git ist im Kommen: • Linux, Android, Eclipse, Ruby on Rails …• Github• Integration in Eclipse, Netbeans, XCode

Page 6: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Git versioniert Repositories, nicht Files

Added File 1

Page 7: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Git versioniert Repositories, nicht Files:• Commit erzeugt neue Version des Repositories• Version ist global eindeutig über Hash-Wert (SHA-1)

Added File 11Commit

Page 8: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Git versioniert Repositories, nicht Files

Added File 11

Edited File 1Added File 2

Page 9: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Git versioniert Repositories, nicht Files

Added File 1

2

1

Edited File 1Added File 2Commit

Page 10: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Branches: Zeiger auf Commits

Added File 1

2

1

Edited File 1Added File 2master

Page 11: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Clonen: Duplizieren des Repositories

Added File 1

2

1

Edited File 1Added File 2master

Added File 1

2

1

Edited File 1Added File 2origin/

master

clone

Page 12: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Arbeiten mit lokalen branches

Added File 1

2

1

Edited File 1Added File 2origin/

master

feature1

Page 13: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Arbeiten mit lokalen branches

Added File 1

2

1

Edited File 1Added File 2origin/

master

feature13

Edited File 2

Page 14: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Arbeiten mit lokalen branches

Added File 1

2

1

Edited File 1Added File 2origin/

master

stefan3 Edited File 2

Added File 1

2

1

Edited File 1Added File 2master

feature13 Edited File 2

push

Page 15: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Wie kommt mein Commit in den zentralen master-branch?

Added File 1

2

1

Edited File 1Added File 2origin/

master

stefan3 Edited File 2

Added File 1

2

1

Edited File 1Added File 2master

feature13 Edited File 2

Page 16: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2011 by Stefan Lay, Edwin Kempin, SAP AG

Git – ein verteiltes Versionierungssystem

   Wie kommt mein Commit in den zentralen master-branch?• Jeder Entwickler pushed direkt • Integrationsmanager merged• Gerrit peer code review

Added File 1

2

1

Edited File 1Added File 2origin/

master

stefan3 Edited File 2

Added File 1

2

1

Edited File 1Added File 2master

feature13 Edited File 2

Page 17: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, SAP AG

Neue* Features in Egit 1.0

* seit 0.9

Release 0.10• Pull• Rebase • Cherry-Pick• Merge tool• http

Authentifizierung

Page 18: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, SAP AG

Neue* Features in Egit 1.0

* seit 0.9

Release 0.10• Pull• Rebase • Cherry-Pick• Merge tool• http

Authentifizierung

Release 0.11• Fetch from Gerrit• Push to / Fetch from Upstream• Tree Compare• Mylyn Integration

Page 19: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, SAP AG

Neue* Features in Egit 1.0

* seit 0.9

Release 0.10• Pull• Rebase • Cherry-Pick• Merge tool• http

Authentifizierung

Release 0.11• Fetch from Gerrit• Push to / Fetch from Upstream• Tree Compare• Mylyn Integration

Release 0.12• Gerrit Configuration• Git config in preferences• Gerrit Mylyn connector

Page 20: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, SAP AG

Neue* Features in Egit 1.0

* seit 0.9

Release 0.10• Pull• Rebase • Cherry-Pick• Merge tool• http

Authentifizierung

Release 0.11• Fetch from Gerrit• Push to / Fetch from Upstream• Tree Compare• Mylyn Integration

Release 0.12• Gerrit Configuration• Git config in preferences• Gerrit Mylyn connector

Release 1.0• Commit Search und Commit Viewer• Staging View• Blame• GitHub Mylyn connector

Page 21: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 by Stefan Lay, SAP AG

Etwas Statistik

* seit 0.9

Zwischen 0.9 und 1.0 1013 commits in EGit 796 commits in JGit

Committer (Contributor): EGit: 15 (47), JGit: 9 (32)

Fixed Bugs 455 egit + jgit

Indigo packages: RCP/RAP, Modeling and LinuxTools

Page 22: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit ?

Code Review | © 2010 by M. Sohn

Page 23: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Server, der die zentralen Git Repositories verwaltet

Code Review | © 2010 by M. Sohn

Gerrit

Page 24: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Access Control

Code Review | © 2010 by M. Sohn

Gerrit

Page 25: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Access Control

Code Review | © 2010 by M. Sohn

Gerrit

Page 26: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Access Control

Code Review | © 2010 by M. Sohn

Gerrit

Page 27: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Access Control

Code Review | © 2010 by M. Sohn

Gerrit

Page 28: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review

Code Review | © 2010 by M. Sohn

Gerrit

Page 29: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review

Code Review | © 2010 by M. Sohn

Gerrit

Page 30: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review

Code Review | © 2010 by M. Sohn

Gerrit

Page 31: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review

Code Review | © 2010 by M. Sohn

Gerrit

Page 37: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Code Review – Vorteile

Vier Augen finden mehr Bugs

Einhaltung von Coding Standards

Mentoring von neuen Entwicklern

Etablierung von Vertrauensverhältnissen

Gute Alternative zu Pair Programming

Code Review | © 2010 by M. Sohn

Guido van Rossum [1]

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

Edwin Kempin
Page 38: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Developer PC

Gerrit

git gitgitgit

Developer PC

gitgit

Hudson

- clone repository - fetch / push changes

- verify proposed changes- continuous integration builds

Copyright © M. Sohn, S. Lay, S. Zivkov, C. Halstrick, C. Aniszczyk, S. Pearce

Page 39: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Copyright © M. Sohn, S. Lay, S. Zivkov, C. Halstrick, C. Aniszczyk, S. Pearce

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

Page 40: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit - Workflow

Code Review | © 2010 by M. Sohn

Page 41: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn http://egit.eclipse.org/r/ - change,825

Page 42: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Was ist sonst noch wissenswert?

Code Review | © 2010 by M. Sohn

Gerrit

Page 43: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn

Gerrit = 4. Generation Code Review @ Google

Page 44: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn

Gerrit = 4. Generation Code Review @ Google

Open Source mit Apache 2 Lizenz

Page 45: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn

Gerrit = 4. Generation Code Review @ Google

Open Source mit Apache 2 LizenzGerrit basiert auf JGit und GWT

Page 46: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn

Gerrit = 4. Generation Code Review @ Google

Open Source mit Apache 2 LizenzGerrit basiert auf JGit und GWTStorage: JGit & DB

Page 47: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn

Gerrit = 4. Generation Code Review @ Google

Open Source mit Apache 2 LizenzGerrit basiert auf JGit und GWTStorage: JGit & DB

wird ersetzt durchJGit only (erster Teil mit Gerrit 2.2)optional: JGit on distributed hashtable (HBase)

-> scalable Gerrit on the Cloud

Page 48: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn

Gerrit = 4. Generation Code Review @ Google

Open Source mit Apache 2 LizenzGerrit basiert auf JGit und GWTStorage: JGit & DB

wird ersetzt durchJGit only (erster Teil mit Gerrit 2.2)optional: JGit on distributed hashtable (HBase)

-> scalable Gerrit on the Clouddemnächst:

Prolog rule engine für konfigurierbare WorkflowsWeb app -> OSGi app for pluggable functionality

Page 49: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit

Code Review | © 2010 by M. Sohn

Gerrit = 4. Generation Code Review @ Google

Open Source mit Apache 2 LizenzGerrit basiert auf JGit und GWTStorage: JGit & DB

wird ersetzt durchJGit only (erster Teil mit Gerrit 2.2)optional: JGit on distributed hashtable (HBase)

-> scalable Gerrit on the Cloud

Verwender:• Android• JGit, EGit• Google, SAP, …• demnächst Eclipse …

Page 50: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

No Free Lunch ? -- DEMO

Code Review | © 2010 by M. Sohn

Page 51: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

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 52: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Code Review – Tips

Small changes are much easier to review

A change should logically do one thing (not many)

No change shall break build or tests

Split big changes into series of digestible changes (patch series)- These changes depend on each other- Last change should switch the new feature on

Commit message should explain Why - The What should be obvious from the code change

Code Review | © 2010 by M. Sohn

Page 53: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Conclusion

Code Review rocks !

Gerrit enables a nice code review workflow

DVCS like Git are powerful

Git supports convenient branching and merging

Git is very fast and scales well

Code Review | © 2010 by M. Sohn

Page 54: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit Code Review

Gerrit developed at http://code.google.com/p/gerrit

https://review.source.android.com/Gerrit for Android projects (also Gerrit)

Code Review | © 2010 by M. Sohn

Page 55: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Git at Eclipse

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

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

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

Code Review | © 2010 by M. Sohn

Page 56: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Features EGit 1.0

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

git-checkout git-mv git-config git-cherry .gitignore

git-cherry-pick git-notes git-fast-export git-count-objects git daemon

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 next release, supported, partial, missing, irrelevant for EGit

Page 57: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Git Resources

Ask questions on the EGit forum or egit-dev/jgit-dev lists

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

If you want comedy, watch Linus' talk at Googlehttp://www.youtube.com/watch?v=4XpnKHJAok8

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

Code Review | © 2010 by M. Sohn

Page 58: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Gerrit Code Review - Outlook

Mylyn Gerrit Connector in incubation

Port from SQL DB to HBase

Git Store:Store review comments as git notes for offline review

Support for change dependencies across repositories

Code Review | © 2010 by M. Sohn

Page 59: Effiziente Entwicklungsprozesse mit Git, EGit und Gerrit - Intland Technology Day Stuttgart 2011/06/08

Code Review | © 2010 by M. Sohn

Gerrit – Rebase