Overview
The Asterisk project uses Gerrit for code reviews, continuous integration validation, and git management. When creating a patch to Asterisk or its various related projects, all patches should be pushed to Gerrit for review.
Use of Gerrit is beyond the scope of this wiki page - for in depth information, see the Gerrit documentation.
Creating an Account
Gerrit uses OpenID in conjunction with the Asterisk project's Atlassian infrastructure to provide single sign-on. If you already have an account in the Asterisk project infrastructure (such as JIRA) and have signed a Contributor License Agreement, you should be able to sign in to Gerrit automatically.
Create an account at signup.asterisk.org.
Sign a Contributor License Agreement.
Browse to Gerrit, and click Sign In.
This will redirect to openid.asterisk.org. Sign in with your Atlassian username/password.
Upon signing in successfully, you will need to authorize Gerrit to access your OpenID. When you have done so, you should be redirected back to Gerrit, and will be signed in.
Setting up your Gerrit Account
Upon logging in for the first time, you will need to perform the following:
- Set your username for your account. This can be any username, although we highly recommend matching your Atlassian username.
- Add your SSH public key.
Cloning from Gerrit
- Clone the repository:
SSH:
HTTP:
Anonymous HTTP:
Copy the
commit-msg
hook into your local.git/hooks
folder:The
commit-msg
hook adds theChange-Id
automatically to git commit messages. AChange-Id
is necessary for Gerrit to associate multiple patch sets together. For more information, see Change-Ids.
Pushing to Gerrit
Pushing to Gerrit for code review is done by pushing to the
refs/for/[branch]
. Generally, this will bemaster
, unless pushing to a particular mainline Asterisk branch.$ git push ssh://{user}@gerrit.asterisk.org:29418/{repo} HEAD:refs/for/master
Since this is done often, it is recommended that you add the following to your
.ssh/config
:This then allows you to push changes using the following:
Updating a Review
Reviews are automatically updated so long as commits contain the same Change ID. If your review has any findings, rebase the commits as appropriate, making sure the Change ID is preserved:
Re-push the changes: