How to Comment on, review, merge

How to Comment, Review, and Merge ”; Previous Next Anyone can review the code and comment on the code in Gerrit. Consider the following steps − Step 1 − Login to Gerrit to open the Gerrit dashboard as specified in the previous chapter. Step 2 − Now, click any subject which contains Gerrit project, branch, updated date, etc. as shown in the following screenshot. Step 3 − Next, it will display a screen. Click the Commit Message option as shown in the following screenshot. The important fields of the change set are like Reviewers, Add Reviewer, Side-by-side off, etc. Comparing patch sets includes selecting the old version history list, expanding the newer patch set details, etc. Reviewing and merging or rejecting the code includes abandon change button, submitting patch button, etc. which are not present in the current version of Gerrit. Print Page Previous Next Advertisements ”;

Gerrit – Useful Resources

Gerrit – Useful Resources ”; Previous Next The following resources contain additional information on Gerrit. Please use them to get more in-depth knowledge on this. Useful Links on Gerrit Gerrit − Official Website of Gerrit. Gerrit Wiki − Wikipedia Reference for Gerrit. Useful Books on Gerrit To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;

Configure Git

Gerrit – Configure Git ”; Previous Next Once you have installed Git, you need to customize the configuration variables to add your personal information. You can get and set the configuration variables by using Git tool called git config along with the -l option (this option provides the current configuration). git config -l When you run the above command, you will get the configuration variables as shown in the following image You can change the customized information any time by using the commands again. In the next chapter, you will learn how to configure the user name and user Email by using git config command. Print Page Previous Next Advertisements ”;

Prepare Push change set to Gerrit

Gerrit – Prepare Push Change Set to Gerrit ”; Previous Next You need to review the changes in Gerrit before merging them into the master. The changes can be synchronized that have occurred in the master. Use the following command within the branch that you have been working on. $ git pull –rebase origin master The above command will fetch the changes or commits from the remote branch and rebase the commits on top of the master. When you are done with the changes and rebased the commits, you can push your change set to Gerrit for review. Git pull –rebase is often used when changes do not deserve a separate branch. Git pull is a combination of git fetch and git merge; where as git pull –rebase is a combination of git fetch and git rebase. First, run the command as git pull origin master as shown in the following screenshot. Now use the command as git rebase master to rebase the commits as shown in the following screenshot. Print Page Previous Next Advertisements ”;

Gerrit – Project Owners

Gerrit – Project Owners ”; Previous Next Project owner means that the project belongs to the person mentioned. Project owners is a virtual group in which you cannot add members or other groups in it. The project owner provides access rights to allow permission on the project to different groups. You can view the access rights of your project using the following steps. Step 1 − Open Gerrit dashboard by clicking this link. Step 2 − Click Projects → List option. Search the project in your project list and click it as shown in the following screenshot. Step 3 − When you open your project, click the Access option as shown in the following screenshot. Step 4 − Click the edit option. You can change the access rights by clicking the dropdown menu. Click the Save Changes button as shown in the following screenshot. Print Page Previous Next Advertisements ”;

Configuring Git-Review

Gerrit – Configuring Git-Review ”; Previous Next Gerrit is built on top of Git version control system, which extracts the code from other host, pushing changes to the code, submitting the code for review, etc. The default remote name of Git is origin and we tell git-review to use this name ”origin” by using the following command. $ git config –global gitreview.remote origin Print Page Previous Next Advertisements ”;

Gerrit – Update Master

Gerrit – Update Master ”; Previous Next You can make the master branch up-to-date using the following command. The git-pull command fetches from another local branch or integrates with another repository. git pull origin master The command will pull changes from the origin remote (URL of remote to fetch from), master branch and merge the changes to local checked-out branch. The origin master is a cached copy of the last pulled from the origin. Git pull is a combination of git fetch (fetches new commits from the remote repository) and git merge (integrates new commits into local branch). Git pull merges the local branch with the remote branch by default. Print Page Previous Next Advertisements ”;

Add SSH Key to your Gerrit Account

Gerrit – Add SSH Key to your Gerrit Account ”; Previous Next SSH key can be added to the Gerrit account using the following steps − Step 1 − First create an account at wmflabs.org services. Step 2 − Next sign in to the web interface for Gerrit. Step 3 − Then in the top right corner, click your username and select the Settings option. Here, we have created an account with the name John to make use of Gerrit Step 4 − Click the “SSH Public keys” option on the left-side menu and paste the SSH Public key in the field. Print Page Previous Next Advertisements ”;

Gerrit – Create Branch

Gerrit – Create a Branch ”; Previous Next You can create a branch on the local machine using the following command. $ git checkout -b name_of_branch origin/master The above command creates a new branch as shown in the following screenshot. Here, we have used branch123 as the new local branch. You can show the new branch from the ”master” using the following command. $ git branch The above command produces the result as shown in the following screenshot. Git checkout navigates between the branch, updates the files in the working directory, and informs Git to record the commits on that branch. Print Page Previous Next Advertisements ”;

Make & Commit Your Change

Gerrit – Make & Commit Your Change ”; Previous Next When you modify the code in the local file system, you can check for the changes within the directory using the following command. $ git diff In the project directory, we will modify some changes in the file called Example/Example.hooks.php and run the above command. We will get the result as shown in the following screenshot. You can check the changes made to the files or the directory using the following command. $ git status The above command allows to see which changes have been staged, which have not, and which files are not tracked by Git. Next, you can add the changes in the working directory and update the file in the next commit using following command. $ git add Example/Example.hooks.php After adding the file, again run the git status command to review the changes added to the staging area as shown in the following screenshot. You can see the difference between the index and your last commit, and what contents have been staged, using the following command. $ git diff –cached You can push the changes to the remote directory from the local repository using the following command. $ git commit When you run the above command, it will ask to add the commit message for your changes. This message will be seen by other people when you push the commit to the other repository. Add the commit message and run the command again as git commit, which will display the commit message as shown in the following screenshot. Print Page Previous Next Advertisements ”;