Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Set your username for your account. This can be any username, although we highly recommend matching your Atlassian username.
  2. 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.

  1. Clone the repository:
    1. SSH:

      Code Block
      $ git clone ssh://{user}@gerrit.asterisk.org:29418/{repo}
    2. HTTP:

      Code Block
      $ git clone http://{user}@gerrit.asterisk.org/{repo}
    3. Anonymous HTTP:

      Code Block
      $ git clone http://gerrit.asterisk.org/{repo}
  2. Copy the commit-msg hook into your local .git/hooks folder:

    Code Block
    $ scp -p -P 29418 {user}@gerrit.asterisk.org:hooks/commit-msg {local-repo}/.git/hooks/

    The commit-msg hook adds the Change-Id automatically to git commit messages. A Change-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 be master, unless pushing to a particular mainline Asterisk branch.

Code Block
$ git push ssh://{user}@gerrit.asterisk.org:29418/{repo} HEAD:refs/for/master

...

Creating an SSH Alias

Since access to gerrit.asterisk.org is likely to occur often, you may want to set up an SSH alias:

Code Block
$ cat ~/.ssh/config
...
Host asterisk
  Hostname gerrit.asterisk.org
  Port 29418
  User {user}

This

...

will allow you to

...

access the repository as shown below:

Code Block
$ git clone asterisk:{repo}

 

Pushing to Gerrit for Code Review

Use git review

  1. Install git-review:

    Code Block
    $ pip install git-review
  2. To submit a change to master:

    Code Block
    $ git review
  3. To submit a change for a particular branch:

    Code Block
    $ git review {branchname}
  4. To submit a change, including the ASTERISK issue:

    Code Block
    $ git review -t ASTERISK-12345

Use git push

 

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.

 

Code Block
$ git push asterisk:{repo} HEAD:refs/for/master

 

 

Updating a Review

  1. 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:

    Code Block
    $ git rebase -i HEAD~{num}
  2. Re-push the changes:

    Code Block
    $ git review

    or:

    Code Block
    $ git push asterisk:{repo} HEAD:refs/for/master

...