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. To set your username:
- Click on your name in the top-right corner.
- Click "Settings"
- Click "Profile" on the left side of the screen.
- In the top text box in the center, enter your user name, and confirm.
- Add your SSH public key.
Cloning from Gerrit
While access to the underlying git repository is open to anyone via anonymous HTTP access, this guide will assume that you want to push changes up as well. For that, Gerrit uses SSH. If you are only looking to obtain the source code for a particular repository, you may just use the HTTP methods shown below.
- Clone the repository:
commit-msghook into your local
Creating an SSH Alias
Since access to gerrit.asterisk.org is likely to occur often, you may want to set up an SSH alias:
This will allow you to access the repository as shown below:
Pushing to Gerrit for Code Review
To submit a change to
masteras a draft:
To submit a change to
Note that this will automatically publish the change to the
To submit a change for a particular branch:
To submit a change, including the
Pushing to Gerrit for code review can always be done using standard
git commands. This is done by pushing to the
refs/for/[branch]. Generally, this will be
master, unless pushing to a particular mainline Asterisk branch.
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:
Patches being submitted to the project must be cherry-picked to other branches when either:
- The patch is a bug fix. In this case, the patch should be cherry-picked to all supported branches that have the bug.
The patch is a new feature or improvement, and tests have been written to cover the new feature or improvement. In that case, the patch may be submitted to other supported branches.
Cherry-picking can be done either when a patch is first proposed, or it may be done when the patch has been reviewed but prior to it being submitted. If you plan on cherry-picking after an initial review, please indicate so in a comment on the review.
Cherry-Picking in Gerrit
If your patch applies cleanly to a branch, you can cherry-pick directly in Gerrit. On your review, select the Cherry-Pick button:
In the resulting dialog, enter the branch you want to cherry-pick to, then select Cherry Pick Change.
If the change merges cleanly, a new review will be opened with your cherry-picked change. If the change could not be merged, and error will appear and you will need to use one of the manual methods listed below.
If you have already submitted a patch for review, you may cherry pick to a new branch using
As an example, if we previously posted for review a code change for Asterisk 11, and the Gerrit Review ID is 30, we might use the following for Asterisk 13:
You may cherry pick using
git cherry-pick as well. When performing the cherry-pick using git, make sure that the
Change-Id header is the same between all branches.
As an example, if we committed the following to Asterisk 13:
We could then cherry pick this back to Asterisk 11 using the following:
The resulting commit must have the same Change-Id as the Asterisk 13 commit for Gerrit to recognize that this is a cherry-picked commit:
When posting it for review to Gerrit, you should also use the same topic as the original patch. Generally, this is the ASTERISK issue.
Problem: attempting to run
git review results in something like the following:
on your command line
Problem: attempting to run
git review results in "unpack failed: error Missing tree":
Description: There is an incompatibility between certain version of git and gerrit that causes this error when the commit to be pushed was amended and only the commit message changed.
Solution: Run git push manually with the --no-thin option: