Gerrit

From Eclipsepedia

Jump to: navigation, search

From TFM: Gerrit is a web based code review system, facilitating online code reviews for projects using the Git version control system. It is not available for CVS or SVN. For more information about Gerrit, please see http://code.google.com/p/gerrit/.

Contents

Using Gerrit hosted at https://git.eclipse.org/r

Enabling Gerrit for your Eclipse.org Project

  • File a bug and specify for which project you'd like to enable Gerrit
  • Ask your Project Lead to +1 the request
  • Choose one of the two options:
    • I want project committers use Gerrit code review exclusively for my project. Everything must be reviewed -- no direct access to the main repo should be available.
    • I want project committers to be able to bypass the Gerrit code review system and push changes directly to the git repo.

User Account

  • In order to contribute you need an Eclipse user account . If you are an Eclipse committer you already have one.
  • Confirm you agree to the Eclipse.org Terms of Service by completing the Individual Contributor agreement.

Logon

Gerrit Web UI
Logon to the Gerrit Web UI using the email address you registered with your Eclipse (and Bugzilla) account and your Eclipse password.
Git over SSH
When accessing Gerrit over SSH from git or EGit use the username displayed here and upload your public SSH key to Gerrit here
Git over HTTPS
When accessing Gerrit over HTTPS from git or EGit use username and HTTP password displayed here

SSH Key Pair

  • Add one or more public SSH keys to Gerrit here.
  • If you are absolutely certain you do not have keys already, you must create a public and private pair of SSH keys. It is strongly recommended that you use a passphrase.
  • Generating SSH key pair on command line
ssh-keygen -t rsa -C "your_email@youremail.com"
  • Execute SSH once to accept the host key (or copy it from the registration web page)
ssh -p 29418 username@git.eclipse.org

Using Gerrit with the git command line:

  • Upload your patch from Git to the target project:
git push ssh://username@git.eclipse.org:29418/(project).git HEAD:refs/for/master

Or, create a new bug and attach a Git formatted patch file, as produced by the `git format-patch` tool.

Adding a dedicated remote

Since git can have multiple remotes, you can define one to be used to refer to Gerrit to save typing. Inside a previously checked-out repository you can run:

cd path/to/project
git config remote.review.url ssh://username@git.eclipse.org:29418/(project).git
git config remote.review.push HEAD:refs/for/master

You can now submit review requests from either repository using:

git push review

Using Gerrit with EGit:

Eclipse will look for your private key in the SSH2 Home location specified in the General>Network Connections>SSH2 Preference Page. If your id_rsa private key makes use of the AES-128-CBC algorithm (view the file as text to confirm), Eclipse will need at least com.jcraft.jsch 0.1.44 to make use of it.

  • Clone the repository and use the last page of the Clone Wizard to configure pushing to the code review queue.
  • Alternative approach adding a review remote in the Git Repositories view:
    • From the appropriate Remotes node, create a New Remote and choose to Configure for Push. A unique name should be chosen, review is suggested.
    • Change the main URI or Add a Push URI (your Gerrit user name must be used here)
      • ssh://username@git.eclipse.org:29418/(project).git
    • In the Ref mapping section, add a RefSpec specification of HEAD:refs/for/master
    • Changes committed to your local clone can now be pushed to Gerrit using the review Remote. You will be prompted for your private key's passphrase if Eclipse is looking for it in the right place.