Versions Compared

Key

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

...

Reference: Gerrit Code Review for Git

OpenECOMP ONAP uses Gerrit to automate the process of reviewing all code changes before they are committed to the Git repository. Here is a tutorial and reference on using Gerrit: https://gerrit.openecomponap.org/r/Documentation/index.html.

...

  1. Move to the folder at the root of your development directory. For example:
    cd C:\Users\<user>\Documents\work
     
  2. Add a remote pointer to the Gerrit server that hosts your repository using either SSH or HTTPS. (Note: <REPONAME>s are given in various Development Guides.
    Using SSH:
    git remote add origin ssh://USERNAME@gerrit.openecomp.org:29418/<REPONAME>

    Using HTTPS:
    With HTTPS, first you will need the Gerrit HTTP-generated password for each HTTPS operation with Gerrit/Git.

    git remote add origin 
    https://USERNAME@gerrit.openecomponap.org/r/a/<REPONAME>
     
  3. Now clone the remote repository. Since we clone in the current folder, it will create a subfolder with the remote copy.
    Using SSH:
    git clone ssh://USERNAME@gerrit.openecomp.org:29418/<REPONAME>

    Using HTTPS:
    With HTTPS, first you will need the Gerrit HTTP-generated password for each HTTPS operation with Gerrit/Git.

    git clone https://USERNAME@gerrit.openecomponap.org/r/a/<REPONAME>

Using IntelliJ to Clone From, and Commit To, Gerrit/Git

Visit https://gerrit.openecomponap.org and log in, using your Linux Foundation identity. Here, you will be able to view the names of Projects to which you have access.

On top of the project listing, the web site provides you the command to clone the whole project, such as:


The project can be downloaded in either of two ways, via HTTP url or SSH url.

IntelliJ and SSH URL (Recommended)

To download the project using an SSH URL, you need to have already added your SSH key into the Gerrit website.

Having added your key, visit https://gerrit.openecomponap.org/r/#/admin/projects/ and select the project you are working on. The Gerrit site will show the full URL for the project:


Next, within IntelliJ, select File -> New -> Project from Version Control -> Git to open the Clone Repository window. Enter the SSH URL from above, including the project name (mso in this example), and chose your local Parent Directory. IntelliJ will fill in the Directory Name for you. Click Clone to clone the project.


For the first downloading, a window will appear to authenticate the host.Click Yes to continue.


IntelliJ and HTTP URL (Alternate Method)

Open IntelliJ and click File -> Settings -> Version Control -> Gerrit. In the resulting dialog box, enter the Gerrit URL as shown above, along with your Linux Foundation username and password. To test whether the connection is good, you can click the Test button:

Info
titlehttps: Required

The URL must use https:, not http:.

Once you have entered this information, click OK:


Then open File -> New -> Project from Version Control -> Git to open Clone Repository window. Enter the http url you have found above, but with https not with http, chose your local Parent Directory and Directory Name and click Clone to clone the project.


A window will pop up to input the user name and password. The user name is the username of your Linux Foundation account, and the password is the Gerrit HTTPS password generated during setup.

Commit Changes Locally

...

The code should now appear in the gerrit web interface. It needs a committer to approve it with a +2 rating, and to also move the verifed flag to +1. The committer does this by visiting the gerrit.openecomponap.org site and logging in.


The committer may take any of several actions, such as clicking on the "Reply" button, adding reviewers, adding a review comment, and moving the flags to +2 and +1

...

Note that you can also work on local branch, Gerrit will automatically use your local branch name as a Topic for the review, allowing you to share branches between team members.


Example Session

  ssh-add onap_rsa

  git clone ssh://username@gerrit.openecomp.org:29418/portal

or via https (note openecomp.org now redirects to onap.org)

obrienbiometrics:onap4 michaelobrien$ git clone https://gerrit.onap.org/r/a/mso

Cloning into 'mso'...

Username for 'https://gerrit.onap.org': michaelobrien

Password for 'https://michaelobrien@gerrit.onap.org': 

remote: Total 4596 (delta 0), reused 4596 (delta 0)

Receiving objects: 100% (4596/4596), 2.94 MiB | 1.68 MiB/s, done.

Resolving deltas: 100% (1985/1985), done.