27
Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit http :// eclipse.org/egit Stefan Lay (SAP) [email protected] Twitter: @stefanlay + =

Eclipse, Git und Gerrit

Embed Size (px)

DESCRIPTION

Slides for the gearconf (mainly in German)

Citation preview

Page 1: Eclipse, Git und Gerrit

 Effiziente Entwicklungsprozesse mit

Eclipse, Git und Gerrithttp://eclipse.org/egit

Stefan Lay (SAP)[email protected]: @stefanlay

+ =

Page 2: Eclipse, Git und Gerrit

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

Agenda

Git – ein verteiltes Versionierungssystem

Git bei Eclipse und innerhalb eines Unternehmens

Code Review mit Gerrit

Demo: Lebenszyklus einer Änderung

Q & A  

Page 3: Eclipse, Git und Gerrit

Effiziente Entwicklungsprozesse mit Eclipse, Git und Gerrit | © 2010 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: Eclipse, Git und Gerrit

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

Geschichte von Git, JGit und EGit

2005    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 3/2010 JGit/EGit Release 0.7 (erstes Release bei Eclipse)                          Diff/Merge Algorithms, Automatic IP Logs 6/2010 Release 0.8 (Helios)            Git Repositories View, Tagging

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

Page 5: Eclipse, Git und Gerrit

5

Git vs. CVS/SVN

Verteilt Historie lokal Offline-Arbeit mit

Versionierung Schnell Einfaches Rebase Sehr gute

Mergeunterstützung -> lokale Feature-Branches

Zentralisiert -- --

Langsam Patches veralten Merge ist problematisch

Understanding and Using Git at Eclipse | © 2010 by C. Aniszczyk, S. Pearce, R. Rosenberg and M. Sohn

Page 6: Eclipse, Git und Gerrit

Eclipse - Rollen

CommitterGewählt in einem formalen ProzessKann eigene Änderungen ohne Review committen

ContributorKleine Änderungen

von Committern gereviewtGrößere Änderungen

zusätzlich formales IP review in speziellem geschützten Bugzilla

Review ToolPatches werden an Bugzilla angehängtKommentare in Bugzilla

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

Page 7: Eclipse, Git und Gerrit

Code Review in Bugzilla

Code Review | © 2010 by M. Sohn

Page 8: Eclipse, Git und Gerrit

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

Git @ Eclipse

EGit/Jgit-Entwicklung: http://egit.eclipse.org

http://git.eclipse.org/ hostet live Eclipse Git Repositories

Virgo, Mylyn Review, ScalaModules, SWTBot …

http://dev.eclipse.org/git/index.html git mirrors für CVS

Read-only Kopien, up-to-dateClonen mit git:// oder http://

“Git is the future SCM of Eclipse (Chris Aniszczyk)”

Page 9: Eclipse, Git und Gerrit

Git innerhalb eines Unternehmens?

• Git wurde für die Entwicklung des Linux Kernels konzipiert

• Verteilte Entwicklung bringt Vorteile für Contributors in Open-Source-Projekten

• Comitter / contributor model auch innerhalb eines Unternehmens -> für re-use-Komponenten

• Produktivität durch lokale Feature branches• Git and Gerrit ermöglichen einen (Peer) Code

review workflow

Page 10: Eclipse, Git und Gerrit

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

Code Review | © 2010 by M. Sohn

Guido van Rossum, Google [1]

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

Page 11: Eclipse, Git und Gerrit

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

Code Review | © 2010 by M. Sohn

Guido van Rossum, Google [1]

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

Page 12: Eclipse, Git und Gerrit

Gerrit Code Review

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

Dient auch als git Server Fügt Zugriffskontrolle und Workflow hinzu

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

Eclipse hat großes Interesse (Bug 283749)…

Code Review | © 2010 by M. Sohn

Page 13: Eclipse, Git und Gerrit

Ein Branch per Feature

Master branch enthält nur akzeptierte ÄnderungenMaster verbessert sich mit jedem Commit

Jeder Feature branch basiert auf dem Master branchStabiler Startpunkt

Neueste Commits in master können leicht in die Änderung integriert werden

Git rebase ist hier sehr hilfreich

Eine Änderung kann leicht verworfen werdenKeine andere Änderung hängt von ihr ab

Code Review | © 2010 by M. Sohn

Page 14: Eclipse, Git und Gerrit

Gerrit - Workflow

Code Review | © 2010 by M. Sohn

Page 15: Eclipse, Git und Gerrit

Gerrit

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

Page 16: Eclipse, Git und Gerrit

Gerrit – Lebenszyklus einer Änderung

a

mastertopic

1

• lokaler Feature Branch• commit• push auf Gerrit• review• automatische Verifizierung

Code Review | © 2010 by M. Sohn

Page 17: Eclipse, Git und Gerrit

Gerrit – Lebenszyklus einer Änderung

c

b

a1

2

mastertopic

3

a

mastertopic

1

• lokaler Feature Branch• commit• push auf Gerrit• review• automatische Verifizierung

• Verbesserung auf Basis des Reviews

• pushen neuer Patch Sets

Code Review | © 2010 by M. Sohn

Page 18: Eclipse, Git und Gerrit

Gerrit – Lebenszyklus einer Änderung

c

b

a1

2

mastertopic

3

a

mastertopic

1

• lokaler Feature Branch• commit• push auf Gerrit• review• automatische Verifizierung

• Verbesserung auf Basis des Reviews

• pushen neuer Patch Sets

c

b

a1

2

master

topic

3

d

• Submit kann zu serverseitigem merge führen

• Alternative: Lokales mergen / rebasen vor dem push

Code Review | © 2010 by M. Sohn

Page 19: Eclipse, Git und Gerrit

Code Review – Unsere Erfahrungen

Alle Änderungen werden gereviewt!

Ein Review kann dauern (1 Tag … Wochen) 

Codeautoren müssen auf den Review warten

Ein paralleler Workflow ist nötig

Jedes Teammitglied sollte sich beteiligen

Git & Gerrit sind außerordentlich hilfreich

Code Review | © 2010 by M. Sohn

Page 20: Eclipse, Git und Gerrit

Code Review – Tipps

Kleine Änderungen

Eine Änderung sollte atomar sein

Eine Änderung sollte weder Build noch Tests brechen

Größere Änderungen sollten in eine Serie von kleineren unterteilt werden (patch series)- Die letzte Änderung schaltet das Feature ein

Die Commit message sollte das Warum erläutern- Das Was sollte aus dem Code klar hervorgehen

Code Review | © 2010 by M. Sohn

Page 21: Eclipse, Git und Gerrit

Understanding and Using Git at Eclipse | © 2010 by C. Aniszczyk, S. Pearce, R. Rosenberg and M. Sohn

No Free Lunch -- DEMO

        

The best way to learn Git is to use Git

Page 22: Eclipse, Git und Gerrit

Understanding and Using Git at Eclipse | © 2010 by C. Aniszczyk, S. Pearce, R. Rosenberg and M. Sohn

Zusammenfassung

DVCS wie z.B. Git sind leistungsstark

Git unterstützt Branches und Merging hervorragend Git ist schnell und skaliert Gerrit ermöglicht einen Review workflow

Git und Gerrit eignen sich für den Einsatz im Unternehmen

Page 23: Eclipse, Git und Gerrit

Understanding and Using Git at Eclipse | © 2010 by C. Aniszczyk, S. Pearce, R. Rosenberg and M. Sohn

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 Google    http://www.youtube.com/watch?v=4XpnKHJAok8

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

Page 24: Eclipse, Git und Gerrit

24

Features EGit 0.8

Supported

Partially supported

Not yet supported

* planned for 0.9

git init / git clone git add git status git commit git diff git fetch git log git merge * git rebase git remote

git pull git push git stash * git branch git tag git checkout git config git format-patch git mv / git rm git reset

.gitignore * synchronize

view *

Page 25: Eclipse, Git und Gerrit

Eclipse – Review Process

Contributors • create patch using CVS, SVN, Git• 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

Code Review | © 2010 by M. Sohn

Page 26: Eclipse, Git und Gerrit

Gerrit - Workflow Every change is reviewed

- Authors can invite reviewers- Complex changes reviewed by many

Look at the change- Comment on how to improve it- Discuss in context of the change

Download the change- test it- improve it

Discussion usually leads to new improved change

Code Review | © 2010 by M. Sohn

Page 27: Eclipse, Git und Gerrit

Code Review

• daily work with code review– improves quality– helps learning and avoiding silos

• review takes time -> parallel workflow -> git helps a lot here

• peer code review and automated verification on isolated change -> voting -> improve change based on comments -> submit to master -> central build and test