Top 50 Gerrit Interview Questions with Answers

Gerrit Interview Questions with Answers

1. What is Gerrit?

A. A collaboration tool for code review
B. A testing framework
C. A version control system

Answer: A

2. Which version control system does Gerrit use?

A. Git
B. SVN
C. Mercurial

Answer: A

3. What is the purpose of Gerrit?

A. To manage code reviews and project collaboration
B. To track bugs and issues in software development
C. To automate deployment process

Answer: A

4. Can Gerrit be used with multiple version control systems?

A. Yes
B. No

Answer: B

5. What is a patch set in Gerrit?

A. A set of changes made to code
B. A predefined set of code changes
C. A bug in the code

Answer: A

6. What is a change request in Gerrit?

A. A request to make a change to the code
B. A change made to the code
C. A request for approval of a patch set

Answer: C

7. What is the Gerrit workflow?

A. Code submission, code review, approval, and merging
B. Code submission, code testing, approval, and merging
C. Code submission, code deployment, approval, and merging

Answer: A

8. What is the role of a Gerrit reviewer?

A. To review and approve changes to the code
B. To submit code changes for review
C. To test the code changes before approval

Answer: A

9. What is a Gerrit bot?

A. A machine learning tool for code review
B. An automated tool for code review
C. A tool for bug tracking

Answer: B

10. Which programming languages does Gerrit support?

A. Java, C++, Python
B. Ruby, C#, Bash
C. Java, Bash, Perl

Answer: A

11. What is the difference between a reviewer and an approver in Gerrit?

A. Reviewers can provide feedback and comments, while approvers have the power to merge changes
B. Reviewers can test the code changes, while approvers only provide approval
C. There is no difference between a reviewer and an approver in Gerrit

Answer: A

12. What is a topic branch in Gerrit?

A. A lightweight branch used for code collaboration
B. A branch used for release management
C. A branch used for bug tracking

Answer: A

13. Can Gerrit be used for non-software development projects?

A. Yes
B. No

Answer: A

14. What is the Gerrit Code Review plugin for Eclipse used for?

A. To submit and review code changes right from the Eclipse IDE
B. To track issues and bugs in Eclipse projects
C. To automate deployment process in Eclipse projects

Answer: A

15. What is the Gerrit REST API used for?

A. To interact with Gerrit programmatically
B. To track issues and bugs in Gerrit
C. To automate deployment process in Gerrit

Answer: A

16. What is the Gerrit configuration file?

A. A file used for configuring the Gerrit server and its behavior
B. A file used for storing code changes
C. A file used for managing users and access controls

Answer: A

17. What is the Gerrit Dashboard?

A. A customizable tool for displaying and organizing reviews and changes
B. A tool for tracking issues and bugs in Gerrit
C. A tool for automated code testing in Gerrit

Answer: A

18. What is the difference between a Gerrit project and a Git repository?

A. A Gerrit project is a collection of Git repositories, while a Git repository is a collection of files and directories
B. A Gerrit project is a Git repository with additional features for code review and collaboration
C. There is no difference between a Gerrit project and a Git repository

Answer: A

19. What are the benefits of using Gerrit for code review?

A. Improved code quality, increased collaboration, and quicker code review process
B. Increased code complexity, lengthy code review process, and decreased collaboration
C. Decreased code quality, decreased collaboration, and no impact on code review process

Answer: A

20. How does Gerrit handle conflicts when merging code changes?

A. By alerting reviewers and allowing them to resolve the conflicts
B. By automatically resolving the conflicts
C. By rejecting the merge request

Answer: A

21. What is the Gerrit plugin architecture?

A. A way to extend Gerrit’s functionality with custom plugins
B. A way to modify Gerrit’s source code
C. A way to integrate Gerrit with third-party tools

Answer: A

22. What is the Gerrit hooks mechanism used for?

A. To trigger custom actions and automate tasks during the code review process
B. To prevent code changes from being submitted
C. To track issues and bugs in Gerrit

Answer: A

23. What is a Gerrit label?

A. A mechanism for defining and enforcing project-specific code review guidelines
B. A mechanism for tracking code changes
C. A mechanism for managing users and access controls

Answer: A

24. What is a Gerrit change ID?

A. A unique identifier for each change request
B. A unique identifier for each reviewer
C. A unique identifier for each merge request

Answer: A

25. What is the Gerrit Code Review plugin for Jenkins used for?

A. To trigger builds and automate testing in Jenkins based on changes submitted to Gerrit
B. To track issues and bugs in Jenkins projects
C. To manage users and access controls in Jenkins

Answer: A

26. What is the Gerrit User Interface written in?

A. GWT (Google Web Toolkit)
B. JavaFX
C. AngularJS

Answer: A

27. What is the Gerrit replication mechanism used for?

A. To keep multiple Gerrit servers in sync
B. To prevent code changes from being submitted
C. To track issues and bugs in Gerrit

Answer: A

28. What is the Gerrit Project Owner role?

A. A role with administrative privileges for managing the project and access controls
B. A role with limited privileges for reviewing code changes
C. A role with automated testing privileges

Answer: A

29. What is a Gerrit group?

A. A way to group users together and assign access controls and privileges
B. A way to group code changes together for review
C. A way to group reviews together for approval

Answer: A

30. What is the Gerrit Commit Message Hook used for?

A. To enforce project-specific guidelines for commit messages
B. To prevent code changes from being submitted
C. To track issues and bugs in Gerrit

Answer: A

31. What is the Gerrit Verification mechanism used for?

A. To automate code testing and review
B. To manage users and access controls
C. To track issues and bugs in Gerrit

Answer: A

32. What is the Gerrit Code Review plugin for Visual Studio used for?

A. To submit and review code changes right from the Visual Studio IDE
B. To track issues and bugs in Visual Studio projects
C. To automate deployment process in Visual Studio projects

Answer: A

33. What is the Gerrit Code Review plugin for IntelliJ IDEA used for?

A. To submit and review code changes right from the IntelliJ IDEA IDE
B. To track issues and bugs in IntelliJ IDEA projects
C. To automate deployment process in IntelliJ IDEA projects

Answer: A

34. What is a Gerrit topic?

A. A way to group code changes together for review
B. A way to track issues and bugs in Gerrit
C. A way to manage users and access controls in Gerrit

Answer: A

35. What is a Gerrit Change-Id label?

A. A way to identify unique changes in Gerrit
B. A mechanism for managing users and access controls
C. A mechanism for tracking issues and bugs in Gerrit

Answer: A

36. What is the Gerrit REST API authentication mechanism?

A. SSH public key authentication
B. HTTP basic authentication
C. OAuth 2.0 authentication

Answer: C

37. What is the Gitweb browser included with Gerrit used for?

A. To browse Git repositories and code changes
B. To browse issues and bugs in Gerrit
C. To manage users and access controls in Gerrit

Answer: A

38. What is Gerrit’s server-side hook mechanism used for?

A. To perform custom actions during the code review process
B. To manage users and access controls in Gerrit
C. To track issues and bugs in Gerrit

Answer: A

39. What is a Gerrit change message?

A. A message associated with a change request providing additional information or justification
B. A message associated with a reviewer providing feedback or comments
C. A message associated with an approver indicating approval or rejection of a change request

Answer: A

40. What is the Gerrit Code Review plugin for GitHub used for?

A. To integrate Gerrit’s code review functionality with GitHub
B. To integrate GitHub’s issue tracking with Gerrit
C. To automate deployment process between Gerrit and GitHub

Answer: A

41. What is the Gerrit Code Review plugin for Bitbucket used for?

A. To integrate Gerrit’s code review functionality with Bitbucket
B. To integrate Bitbucket’s issue tracking with Gerrit
C. To automate deployment process between Gerrit and Bitbucket

Answer: A

42. What is the Gerrit Code Review plugin for GitLab used for?

A. To integrate Gerrit’s code review functionality with GitLab
B. To integrate GitLab’s issue tracking with Gerrit
C. To automate deployment process between Gerrit and GitLab

Answer: A

43. What is the difference between a Gerrit reviewer and a Gerrit approver?

A. Reviewers provide feedback and comments, while approvers have the power to merge changes
B. Reviewers test the code changes, while approvers only provide approval
C. There is no difference between a Gerrit reviewer and a Gerrit approver

Answer: A

44. How does Gerrit handle merge conflicts with multiple reviewers?

A. By allowing reviewers to resolve conflicts and re-submit the changes
B. By automatically resolving conflicts and merging the changes
C. By rejecting the changes and requiring further review

Answer: A

45. What is Gerrit’s out-of-the-box access control mechanism?

A. A permission-based access control system
B. A role-based access control system
C. A time-based access control system

Answer: A

46. What is the Gerrit Code Review plugin for Jira used for?

A. To integrate Gerrit’s code review functionality with Jira issue tracking
B. To integrate Jira’s issue tracking with Gerrit
C. To automate deployment process between Gerrit and Jira

Answer: A

47. What is the Gerrit Code Review plugin for Redmine used for?

A. To integrate Gerrit’s code review functionality with Redmine issue tracking
B. To integrate Redmine’s issue tracking with Gerrit
C. To automate deployment process between Gerrit and Redmine

Answer: A

48. What is the Gerrit Code Review plugin for Trello used for?

A. To integrate Gerrit’s code review functionality with Trello project management
B. To integrate Trello’s project management with Gerrit
C. To automate deployment process between Gerrit and Trello

Answer: A

49. What is a Gerrit change status?

A. A status indicating the current state of a change request, such as “Open” or “Merged”
B. A status indicating the current state of a reviewer, such as “Approved” or “Rejected”
C. A status indicating the current state of an approver, such as “Merged” or “Abandoned”

Answer: A

50. What is the Gerrit Code Review plugin for Slack used for?

A. To send notifications and updates about code changes and reviews to Slack channels
B. To integrate Slack messaging with Gerrit’s code review functionality
C. To automate deployment process between Gerrit and Slack

Answer: A

Best Branching and Merging strategies in Gerrit

Best Branching and Merging strategies in Gerrit

Step 1 – First Lets read this article about Best Branching and Merging strategies in git

Best Branching and Merging strategies in git

Step 2 – Now Lets learn the Gerrit Merge Types
https://nofluffjuststuff.com/magazine/2016/04/understanding_and_applying_gerrit_part_3_gerrit_submit_types_and_git_review

Step 3 – Time to Learn the Types of Submit in Gerrit
https://gerrit-review.googlesource.com/Documentation/project-configuration.html

Step 4 – Finally, You must read the recommendations below
https://hyperledger-fabric.readthedocs.io/en/release-1.2/Gerrit/best-practices.html

Tagged : / / / / /

How to revert the changes once its submitted in Gerrit

How to revert the changes once its submitted in Gerrit

The Revert button is available if the change has been submitted. This Reverts the change via creating a new one. When the Revert button is pressed, a panel will appear to allow the user to enter a commit message for the reverting change.

Once a revert change is created, the original author and any reviewers of the original change are added as reviewers and a message is posted to the original change linking to the revert.

However, patchsets can not be reverted. so first you have to checkout one of the previous patchset. you can get the command from Gerrit review board at each patchset download panel. After checking it out amend it to generate new commit hash then pushed again as a new patchset.

If I have multiple patch set versions for one change in Gerrit, You can only submit the latest patch set version. The design assumes that the most recent patch set is the one developers will review and test, and as such older patch sets can not be submitted.

Good Read
http://www.saros-project.org/node/155

Tagged : / / / / / /

What is a Change and Patch set in Gerrit?

Here is the short and quick description of Gerrit key teminology.

Change

Every time you push a commit with a new Change-Id Gerrit allocates a new change. Every change has a unique Change-Id and a Change Number. The change contains a number of patch sets, comments on the patch sets and a code review rating (+2, +1, 0, -1, -2). Each change has a dedicated page that shows information about it called individual change page. This includes dependencies between different changes, patch sets and the review comments.

Submit

Once a change has received a +2 in the Code Review and no negative voting in the other categories the last patchset can be submitted. This means Gerrit will now try to cherry-pick your patch set and mark the change as merged.

Patch set

If you want to modify your change, you don’t have to push a new change to Gerrit but only a new patch set . Imagine a patch sets as different versions or revisions of a change. Each patch set can receive inline comments. Gerrit uses the Change-Id of a commit message to identify patch sets of a change. This is why all patch sets of a change have the same Change-Id.

To create a new Patch when new changes are submitted
Step 1: Install commit-msg hooks for gerrit

$ scp -p -P 29418 localhost:hooks/commit-msg .git/hooks/

 

 

Step 2: Create normal commit and push (for Patchset1)

for example:

git add Server.java
git commit -m "server added"
git push origin HEAD:refs/for/master

 

 

Step 3: After doing some changes to Server.java

Finally to create new Patchset (Patchset 2)

git add Server.java
git commit --amend
git push origin HEAD:refs/for/master
Repeat step 3 for further Patches

Understanding the Patch set in Git perspective

Git is a very advanced distributed source code control system. Maintaining patch sets (often called a topic branch) in Git. Git includes a rebase capability that is very useful for a number of different operations related to maintaining a branch of code including moving a branch forward, moving a branch around on an upstream branch to look for breakage, and merging changesets to create patch files.

Git: How to create and apply patches

Creating a patch

Make your changes and commit them.
Run $ git format-patch COMMIT_REFERENCE #to convert all commits since the referenced commit (not including it) into patch files.
$ git format-patch HEAD~~

This will create 2 files, one for each commit since HEAD~~, like these:
0001-make-stuff-more-awesome.patch
0002-allow-users-to-be-locked.patch

Applying patches
You can use git apply some.patch to have the changes from the .patch file applied to your current working directory. They will be unstaged and need to be committed by you.

To apply a patch as a commit (with its commit message), use git am some.patch. \
For all patches to be applied, simply run:
$ git am *.patch

Note that in some previous version you could pass the latest patch filename of a list of patches to apply all previous patches as wel
$ git am 0002-allow-users-to-be-locked.patch # May no longer work for you

You then have the 2 unpushed commits from the patch file created earlier.

Tagged : / / / /

How to replace Changes after the Gerrit review without changing the commit id?

How to replace Changes after the Gerrit review without changing the commit id?

One of the main benefits of code review is the ability to receive and incorporate feedback from other developers without changing the commit-id and review id. With Gerrit, you incorporate these changes by amending the commit. Gerrit uses the CHange-Id to ensure that each iteration of the commit are stored together as patchsets.

The process of modify same commit and commit message on gerrit after patchset creation is pretty straight forward.

Step 1 – Do the required modification in the code based on the review.

Step 2 – Add files using git add commands.

$ git add filename

Step 3 – Command to update/amend the most recent commit.

$ git commit --amend

When amending a commit with git commit –amend, leave the Change-Id line unmodified in the commit message. This will allow Gerrit to automatically update the change with the amended commit.

Step 4 – Gerrit updates the commit under review with your latest changes.

$ git push origin HEAD:refs/for/master
$ git push origin HEAD:refs/for/[BRANCH_NAME]
Tagged : / / / / / / /

How to compile and build Gerrit Plugins?

To build Gerrit Plugins from source, you need:

A Linux or macOS system (Windows is not supported at this time)

zip, unzip, wget

$yum install zip -y
$ yum install unzip -y
$ yum install wget -y
$ yum install git -y

Python 2 or 3
This is installed in each RHEL 7 and Ubunutu server by defaul.

Node.js

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
OR
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum -y install nodejs

Bazel

## RHEL/CentOS 7 64-Bit ##
$ wget https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo
$ cp vbatts-bazel-epel-7.repo /etc/yum.repos.d/
$ yum install -y bazel

How to Installing Bazel on Ubuntu?
https://docs.bazel.build/versions/master/install-ubuntu.html

Maven

$ cd /opt
$ wget http://www-us.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip
$ unzip apache-maven-3.5.4-bin.zip
$ mv apache-maven-3.5.4 maven
$ export PATH=$PATH:/op/maven/bin

gcc

$ sudo yum install gcc-c++ make

Now, Bazel in tree driven means it can only be built from within Gerrit tree. Clone or link the plugin into gerrit/plugins directory:

# First become a non-root user

A JDK for Java 8

$ cd
$ wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz
$ tar -xvf jdk-8u181-linux-x64.tar.gz
$ export JAVA_HOME=/home/ec2-user/jdk1.8.0_181
$ java -version

Follow for Gerrit.war

$ git clone --recursive https://gerrit.googlesource.com/gerrit
$ cd gerrit 
$ bazel build release

Follow for plugins such as its-jira

$ cd plugins
$ git clone https://gerrit.googlesource.com/plugins/its-jira
$ git clone https://gerrit.googlesource.com/plugins/its-base
$ bazel build plugins/its-jira

The output can be normally found in the following directory:

bazel-genfiles/plugins/its-jira/its-jira.jar

# Some plugins describe their build process in src/main/resources/Documentation/build.md file. It may worth checking.

# Some plugins cane be build using maven as well

Reference

  • https://gerrit-review.googlesource.com/Documentation/dev-bazel.html
  • https://gerrit.googlesource.com/gerrit/
  • https://gerrit-review.googlesource.com/Documentation/cmd-plugin-install.html
  • https://gerrit-review.googlesource.com/Documentation/dev-build-plugins.html
Tagged : / / / /

What is “Install Verified label” in Gerrit?

What is “Install Verified label” in Gerrit?

The Verified label was originally invented by the Android Open Source Project to mean ‘compiles, passes basic unit tests’. Some CI tools expect to use the Verified label to vote on a change after running.

During site initialization the administrator may have chosen to configure the default Verified label for all projects. In case it is desired to configure it at a later time, administrators can do this by adding the following to project.config in All-Projects:

[label “Verified”]
function = MaxWithBlock
value = -1 Fails
value = 0 No score
value = +1 Verified
copyAllScoresIfNoCodeChange = true
The range of values is:

-1 Fails
Tried to compile, but got a compile error, or tried to run tests, but one or more tests did not pass.
Any -1 blocks submit.

0 No score
Didn’t try to perform the verification tasks.

+1 Verified
Compiled (and ran tests) successfully.
Any +1 enables submit.

For a change to be submittable, the change must have a +1 Verified in this label, and no -1 Fails. Thus, -1 Fails can block a submit, while +1 Verified enables a submit.

Additional values could also be added to this label, to allow it to behave more like Code-Review (below). Add -2 and +2 entries to the label.Verified.value fields in project.config to get the same behavior.

As an example, the popular gerrit-trigger plugin for Jenkins/Hudson can set labels at:

  • The start of a build
  • A successful build
  • An unstable build (tests fails)
  • A failed build

Usually the range chosen for this verdict is the Verified label. Depending on the size of your project and discipline of involved developers you might want to limit access right to the +1 Verified label to the CI system only. That way it’s guaranteed that submitted commits always get built and pass tests successfully.

If the build doesn’t complete successfully the CI system can set the Verified label to -1. However that means that a failed build will block submit of the change even if someone else sets Verified +1. Depending on the project and how much the CI system can be trusted for accurate results, a blocking label might not be feasible. A recommended alternative is to set the label Code-review to -1 instead, as it isn’t a blocking label but still shows a red label in the Gerrit UI. Optionally, to enable the possibility to deliver different results (build error vs unstable for instance), it’s also possible to set Code-review +1 as well.

If pushing new changes is granted, it’s possible to automate cherry-pick of submitted changes for upload to other branches under certain conditions. This is probably not the first step of what a project wants to automate however, and so the push right can be found under the optional section.

Suggested access rights to grant, that won’t block changes:
Read on ‘refs/heads/*’ and ‘refs/tags/*’
Label: Code-Review with range ‘-1’ to ‘0’ for ‘refs/heads/*’
Label: Verified with range ‘0’ to ‘+1’ for ‘refs/heads/*’

Optional access rights to grant:
Label: Code-Review with range ‘-1’ to ‘+1’ for ‘refs/heads/*’
Push to ‘refs/for/refs/heads/*’

Reference
https://gerrit-review.googlesource.com/Documentation/config-labels.html#label_Verified
https://gerrit-review.googlesource.com/Documentation/access-control.html#examples_cisystem
https://groups.google.com/forum/#!topic/repo-discuss/FdN29piSmEQ

Tagged : /

What is Enable signed push support in Gerrit?

This options Defaults to false.

This ensure When a client pushes with git push –signed, this ensures that the push certificate is valid and signed with a valid public key stored in the refs/meta/gpg-keys branch of All-Users.

If true, server-side signed push validation is enabled.

Config in gerrit.config – receive.enableSignedPush

Tagged : / / / / /

Importannce of Canonical web url in Gerrit

The canonical web url must be set. Optional base URL for repositories available over the anonymous git protocol. For example, set this to git://mirror.example.com/base/ to have Gerrit display patch set download URLs in the UI. Gerrit automatically appends the project name onto the end of the URL.

By default unset, as the git daemon must be configured externally by the system administrator, and might not even be running on the same host as Gerrit.

Tagged : /