Gerrit/Getting started
|
This is a very short guide to using Git and Gerrit for MediaWiki development. For more details, check Gerrit/Tutorial and Gerrit/Advanced usage.
Setup git:
Setup account in our infrastructure:
- Create a developer account
- Login and add your public key to gerrit
- Install git-review
Get the code:
$ git clone ssh://USERNAME@gerrit.wikimedia.org:29418/mediawiki/core.git$ git clone ssh://USERNAME@gerrit.wikimedia.org:29418/mediawiki/extensions/EXTENSION.git
Write and send new code:
$ git checkout master$ git pull$ git checkout -b MEANINGFUL_BRANCH_NAME # Branch naming tips are available.# Now write some code. Then, when you're ready:$ git commit --all # In the Gerrit world you can do this only once per branch! Remember to follow the commit message guidelines.$ git show HEAD # Make sure that you are sending what you wanted to send.$ git review
Go to Gerrit, click your change and write a reviewer name in the input box near the "Add Reviewer" button. If you don't know who to invite, try the maintainer for the component you've edited, or ask on IRC.
If the reviewer asks you to make changes, you'll have to make them and amend your change:
$ git checkout master$ git pull$ git review -d CHANGE_ID # e.g. 1234 in gerrit.wikimedia.org/r/1234# Make the needed changes to the source files.$ git commit --all --amend # You can do this more than once. If you change the commit message, make sure to leave the "Change-Id" line intact! (see note below)$ git review --no-rebase # This creates a new patch set in Gerrit, and sends an invitation to review the code again.
CHANGE_ID.
Note: if you do "git commit --all --amend -m 'my new commit message'" then git will SILENTLY create a new Change-Id and thus a new entry in the branch in gerrit instead of a new patchset, which is probably not what you wanted to do. Use a local editor for commit messages for patchsets and not the "-m" option.