The Gerrit Code review tool.

The Gerrit Code review tool.

The outreachy contributing phase just ended, and as a successful applicant for the initial application, I chose a Wikimedia project for the contributing phase. Wikimedia uses phabricator for managing and creating tasks and Gerrit for hosting their Code repositories, making open source contributions, and code review. When this phase began, it was my first time knowing about and I was quite confused initially understanding how to use these tools.

Like with me, perhaps this is your first time hearing Gerrit, and you might be wondering, "What is Gerrit". Let's go on you would find out more about this.

This article would provide an overview of Gerrit.

What is Gerrit?

Gerrit: just like Github, Gitlab, Bit-bucket, or any other code-review tool, it is a web-based code review tool built on git version control that provides a framework you and your teams can use to review code before it becomes part of the codebase.

Some Awesome Features of Gerrit.

  • Commits made to Gerrit are done in Patches called Patch sets.
  • Gerrit allows for the addition of code reviewers on patches.
  • On Gerrit, commits made are automatically assigned a Change-Id which can be seen once the first patch is made on a branch.
  • It also presents you with buttons you could either use to rebase, abandon, restore an abandoned patch, revert a merged patch or make edits to your changes.
  • If for some reason you lose your local files, after making commits to your Gerrit account, Gerrit provides you with an option to download the exact patch you need, with the change previously made to the Patch and any sub-patch on the parent patch.
  • All files where changes are made in a patch-set are listed out, as seen here. nggh.png
  • Gerrit allows for comments on changes to be made directly on the affected area, by simply highlighting the area and pressing "c" on your keyboard, a comment box appears, where you can now enter your comment, save, then at the top of the commit page, click on reply to send your comment. as seen here. comment.png comm.png
  • It provides you with a Graphical User Interface (G.U.I) that allows for making edits to affected files as seen here;

edits.png

This allows for efficient and more specific ways of communication between the reviewer and contributor. For example;

mi.png

Here, I placed a comment on Line 221 of the script/pagefromfile.py file. It shows a descriptive hyperlink showing the affected file and the line. Clicking on the file name takes you to the file script/pagefromfile.py, and clicking on line 221 takes you to the point where the comment was made.

  • Like your social platform chats are organized in sequential order, Gerrit organizes uploaded patches, their corresponding comments, and subsequent patches in their order of arrival sequentially, this helps users track recent comments and patches as seen below.

Screenshot from 2020-10-31 23-06-02.png

An Overview of Some Gerrit Functionalities

For this article, I would use my Wikimedia Gerrit account to explain further. Here is an overview of a Gerrit GUI.

ovv.png

As seen from the image above, there are some differences between Gerrit and other code review tools you know. Let me walk you through the functionalities of the different sections of this tool using the numbered areas in the diagram.

  1. This shows the status of your commit, which can be:

    • Active: indicates your commit is still in the review process.
    • Merged: indicates your commit has been reviewed and merged to the codebase.
    • Abandoned: indicates your commit/patch set would not be reviewed and has been dropped from the review list.
    • Merge Conflict: indicates your patch set has a conflict with the codebase.
  2. This is the last number associated with your commit in the URL.

  3. This contains the commit message as seen in the image,

    • [IMPR] Rewrite scripts new option handler.
    • The Id of the issue, like Bug: T264721.
    • Change-Id: the number automatically associated with your patch set on successful commit.
  4. Changes includes the following;

    • Open: shows all open commits/patch-sets.
    • Merged: shows all merged commits/patch-sets.
    • Abandoned: shows all abandoned commits/patch-sets.
  5. Reply: This is where you can add comments if you do not want to comment on a particular code area.

  6. Your: consists of the following;

    • Dashboard: This leads you to your personal dashboard as seen here; nnn.png
    • Draft Comments: This shows all unsent comments on patchsets.
    • Edits: This shows all patch-sets you have made edits to its code.
    • Watched Changes
    • Starred Changes
    • Groups: points to the group section under your settings.
  7. Documentation: this covers the documentation of the gerrit tool and contains the following;

    • Table of content: shows the documentation for the gerrit review tool , you can read this to understand more about this tool and how to interact with it.
    • Searching: launches the search option of the documentation.
    • Uploading
    • Access Control
    • RESTAPI
    • Project Owner guide
  8. Browse: this contains the following:

    • Repositories: lists code repositories under a project.
    • Plugins: lists all plugins under a project.
    • Groups: lists groups within a project.
    • Code search: allows search for codes within repositories in a project.
  9. Search Bar: allows searches to be made across the contents of a project.

  10. Add reviewer: here you can add reviewers to your patchset. For example, I added Xqt, Jenkins bot, and xSavitar as reviewers to this patch-set.

  11. This shows the status of tests performed on your patchset. For example, this patch-set passed all tests and the status as shown below indicates success. statuscheck.png

  12. Rebase: option for integrating changes to your patch.

  13. Abandon: option for dropping a patch-set.

  14. Edit: option to edit the code in a patch-set from the Gerrit GUI.

  15. This includes the following options:

    • Download Patch: allows you to download the exact patch-set with all the previous changes made to the patch.
    • Mark reviewed
    • Cherry Pick
  16. Here you can view and edit your profile settings and other settings on Gerrit.

  17. Merge Conflicts: this shows patches with merge conflicts from other contributors and if any merge conflicts your own contributions.

  18. Restore: the restore option allows you to restore an abandoned patch-set. nnn.png

  19. Revert: the revert option allows you to revert a merged patch-set. nnn.png

Hope this was helpful, you can leave a comment or your choice emoji.

Thank you for reading, I would love to connect with you at Twitter .

Do share your valuable feedback and suggestions!