Gerrit
From collectd Wiki
Gerrit is a code review tool for Git. We were evaluating its use for collectd for a while but ultimately decided against using it.
Contents |
Getting started
Create an account
- Visit https://collectd.org/gerrit/
- Log in using an OpenID (http://openid.net/)
- Pick a unique user name and upload at least one SSH key. The user name will be referenced as
$USERbelow.
Setting up your repository
If you have not yet done so, clone the collectd repository:
git clone 'git://git.verplant.org/collectd.git' cd collectd
Add a remote named “gerrit” to your Git repository:
git remote add gerrit "ssh://${USER}@collectd.org:29418/collectd"Install the appropriate commit-msg hook:
scp -p -P 29418 "${USER}@collectd.org:hooks/commit-msg" .git/hooks/
Submitting changes
You need to specify which branch a change should go into. Information on how the branches are organized is available on the Repository page. In short, bug fixes go in the earliest (still maintained) branch they apply to, features go into master. We'll call this ${DEST_BRANCH} for now.
git push gerrit "HEAD:refs/for/${DEST_BRANCH}"Updating changes
Once your code has been reviewed, you may be asked to make changes. It looks like Gerrit doesn't allow you to upload a new commit based on your previous change, but wants you to edit the existing commit. You can use git commit --amend to add changes to the previous commit:
# Create feature branch based on ${DEST_BRANCH}. git checkout -b new_feature "${DEST_BRANCH}" # Heavy-duty coding … # Create commit. git commit -a -m 'Awesome new feature. Behold!' # Create a new change in Gerrit. git push gerrit "new_feature:refs/for/${DEST_BRANCH}" # Get your code reviewed. # More heavy-duty coding … git add --update git commit --amend # Update the change in Gerrit. git push gerrit "new_feature:refs/changes/${CHANGE_ID}"
As an alternative, if you already committed multiple commits, you can use git rebase --interactive to “squash” the commits together:
# Create feature branch based on ${DEST_BRANCH}. git checkout -b new_feature "${DEST_BRANCH}" # Heavy-duty coding … # Create commit. git commit -a -m 'Awesome new feature. Behold!' # Create a new change in Gerrit. git push gerrit "new_feature:refs/for/${DEST_BRANCH}" # Get your code reviewed. # More heavy-duty coding … git add --update git commit -m 'Update.' # Squash all commits based on ${DEST_BRANCH} into one: git rebase --interactive "${DEST_BRANCH}" # An editor opens, asking you what to do with the commits. # Leave "pick" for the first commit, change all other commits to "squash". # Update the change in Gerrit. git push gerrit "new_feature:refs/changes/${CHANGE_ID}"
Writing feedback / Responding
To write feedback on a particular line, just double-click on this line in the side-by-side view and a text-box will open. To reply to posted comments you can link the Reply button. The Done button will reply with the fixed string "Done.", implying that you fixed whatever the reviewer has picked upon.
After you've written comments and/or replies, they will be stored as Draft, meaning nobody but yourself can see them. In order to make them visible to the public, go to the main page of that change and hit the Review button.

