Author: | Yuriy Taraday |
---|---|
Contact: | yorik.sar@gmail.com; ytaraday@mirantis.com |
Outline should be:
Forked because Guido didn't want to complicate Rietveld code with ACL stuff
Gerrit Rietveld - Dutch architect Guido is fond of
Apache Mina SSH daemon - some claim it's slow, but it looks like it's enough for entire Android community
Gerrit manages authoritative repo, all changes are first stored in separate area for review and are merged to repo's branches only on successful review.
Developers and CI infrustructure fetch code from that repo.
Gerrit also provides very powerfull access control stuff.
It's very simplified.
Picture shows workflow used by Android community.
Basically everything's the same as at previous picture, but with more details
URL looks like: ssh://<USER>@<host>:29418/<PROJECT>
Create a new change:
git push gerrit HEAD:refs/for/thebranch
Fetch patchset (access later through FETCH_HEAD):
git fetch gerrit refs/changes/<ID_mod100>/<SHORT_ID>/<PATCHSET_NUM>
Create a new patchset in a change:
git push gerrit HEAD:refs/changes/<SHORT_ID>
You might even need to do something like this:
git push gerrit HEAD:refs/for/master HEAD~3:refs/changes/1500 HEAD~1:refs/changes/1501 HEAD~0:refs/changes/1502
Every change request has a long id that looks like 'I' + SHA
If it is in commit message, Gerrit will always treat this commit as a patchset for this change:
Short commit description Some long lines about life, the Universe and everything. Change-Id: Ic0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ff
Gerrit comes with a commit message hook that automatically generates Change-Id line in every commit:
scp -p -P 29418 <USER>@<HOST>:hooks/commit-msg .git/hooks/ curl -o .git/hooks/commit-msg http://<HOST>/tools/hooks/commit-msg
Short demo
Problems:
OpenStackers created git-review tool
install:
pip install git-review
almost all you need is:
git review
OpenStack wanted to migrate to Gerrit, but it was too complex
Internally git-review uses gerrit command line interface
You should have .gitconfig file in repo to let every user benefit from git-review
[gerrit] host=gerrit.example.com port=29418 project=myopenstack/keystone defaultremote=gerrit-myopenstak defaultbranch=longlived-branch
defaultremote allows to use one repo with several Gerrits (internal and upstream)
defaultbranch leaves no place to forget where to push
File should be created/edited by project/branch maintainer.
Merges should not affect it.
defaultbranch is pretty recent
clone repo
install commit_msg hook, and create remote
git review -s
rebase on top of fresh upstream and push changes
git review
list pending changes
git review -l
get one of them to separate local branch
git review -d <SHORT_ID>
more in help page