â€⢠Worked on Gerrit to Merge Changes to the Git Repository After Reviews Are Done
To understand how Gerrit works, allow'southward follow a alter through its unabridged life cycle. This case uses a Gerrit server configured as follows:
-
Hostname: gerrithost
-
HTTP interface port: fourscore
-
SSH interface port: 29418
In this walkthrough, we'll follow ii developers, Max and Hannah, as they brand and review a change to a RecipeBook project. Nosotros'll follow the change through these stages:
-
Making the change.
-
Creating the review.
-
Reviewing the change.
-
Reworking the change.
-
Verifying the change.
-
Submitting the modify.
Annotation | The project and commands used in this section are for demonstration purposes but. |
Making the Change
Our kickoff programmer, Max, has decided to make a alter to the RecipeBook project he works on. His start pace is to get the source lawmaking that he wants to alter. To get this code, he runs the following git clone
control:
git clone ssh://gerrithost:29418/RecipeBook.git RecipeBook
After he clones the repository, he runs a couple of commands to add a Change-Id to his commits. This ID allows Gerrit to link together different versions of the same change being reviewed.
scp -p -P 29418 gerrithost:hooks/commit-msg RecipeBook/.git/hooks/ chmod u+ten .git/hooks/commit-msg
Note | To learn more nearly adding a change-id and the commit message hook, see the commit-msg Hook topic. |
Creating the Review
Max'south next step is to push his change to Gerrit and so other contributors can review it. He does this using the git push origin HEAD:refs/for/main
command, as follows:
$ <piece of work> $ git commit [master 3cc9e62] Modify to a proper, yeast based pizza dough. 1 file changed, ten insertions(+), 5 deletions(-) $ git button origin Head:refs/for/master Counting objects: three, done. Delta pinch using upwards to viii threads. Compressing objects: 100% (2/2), washed. Writing objects: 100% (3/3), 532 bytes | 0 bytes/southward, done. Full 3 (delta 0), reused 0 (delta 0) remote: Processing changes: new: 1, washed remote: remote: New Changes: remote: http://gerrithost/#/c/RecipeBook/+/702 Modify to a proper, yeast based pizza dough. remote: To ssh://gerrithost:29418/RecipeBook * [new co-operative] HEAD -> refs/for/master
Notice the reference to a refs/for/chief
branch. Gerrit uses this branch to create reviews for the master branch. If Max opted to push to a different branch, he would have modified his command to git push origin HEAD:refs/for/<branch_name>
. Gerrit accepts pushes to refs/for/<branch_name>
for every branch that it tracks.
The output of this command likewise contains a link to a web page Max can apply to review this commit. Clicking on that link takes him to a screen like to the following.
Figure 1. Gerrit Code Review Screen
This is the Gerrit code review screen, where other contributors tin review his change. Max can too perform tasks such every bit:
-
Looking at the unequal of his change
-
Writing inline or summary comments to enquire reviewers for advice on particular aspects of the alter
-
Calculation a list of people that should review the alter
In this case, Max opts to manually add the senior developer on his squad, Hannah, to review his alter.
Reviewing the Modify
Permit's at present switch to Hannah, the senior developer who will review Max's alter.
As mentioned previously, Max chose to manually add Hannah equally a reviewer. Gerrit offers other ways for reviewers to find changes, including:
-
Using the search feature that to find changes
-
Selecting Open from the Changes menu
-
Setting up email notifications to stay informed of changes even if you lot are not added equally a reviewer
Because Max added Hannah every bit a reviewer, she receives an email telling her about his change. She opens up the Gerrit code review screen and selects Max's modify.
Observe the Label status section in a higher place:
Label Status Needs label: * Code-Review * Verified
These two lines indicate what checks must be completed before the change is accepted. The default Gerrit workflow requires 2 checks:
-
Code-Review. This cheque requires that someone expect at the code and ensures that it meets project guidelines, styles, and other criteria.
-
Verified. This check means that the code actually compiles, passes whatever unit tests, and performs as expected.
In general, the Lawmaking-Review check requires an private to look at the lawmaking, while the Verified check is done by an automated build server, through a mechanism such equally the Gerrit Trigger.
Important | The Lawmaking-Review and Verified checks require different permissions in Gerrit. This requirement allows teams to separate these tasks. For case, an automated process tin can have the rights to verify a change, but non perform a code review. |
With the lawmaking review screen open, Hannah can brainstorm to review Max'due south alter. She tin can choose one of ii ways to review the change: unified or side-past-side. Both views allow her to perform tasks such every bit add inline or summary comments.
Hannah opts to view the change using Gerrit's side-by-side view:
Effigy two. Side By Side Patch View
Hannah reviews the change and is ready to provide her feedback. She clicks the REPLY button on the alter screen. This allows her to vote on the change.
Effigy 3. Reviewing the Change
For Hannah and Max'south team, a code review vote is a numerical score betwixt -2 and two. The possible options are:
-
+two Looks proficient to me, canonical
-
+i Looks proficient to me, but someone else must corroborate
-
0 No score
-
-one I would adopt this is not submitted as is
-
-2 This shall non be submitted
In add-on, a change must have at least 1 +2
vote and no -2
votes earlier it can be submitted. These numerical values do not accumulate. Two +1
votes do not equate to a +2
.
Hannah notices a possible consequence with Max'due south change, so she selects a -1
vote. She uses the Cover Message text box to provide Max with some boosted feedback. When she is satisfied with her review, Hannah clicks the SEND button. At this bespeak, her vote and embrace message become visible to to all users.
Reworking the Alter
Subsequently in the solar day, Max decides to check on his change and notices Hannah'due south feedback. He opens upward the source file and incorporates her feedback. Considering Max's change includes a change-id, all he has to practise is follow the typical git workflow for updating a commit:
-
Cheque out the commit
-
Amend the commit
-
Rebase the commit if needed
-
Button the commit to Gerrit
$ <checkout first commit> $ <rework> $ git commit --better [main 30a6f44] Change to a proper, yeast based pizza dough. Date: Fri Jun eight xvi:28:23 2018 +0200 1 file changed, ten insertions(+), five deletions(-)
At this signal Max wants to make sure that his change is on meridian of the co-operative.
Max got no output from the fetch command, which is skilful news. This ways that the master branch has not progressed and there is no need for rebase. Max is now ready to push his modify:
$ git push button origin HEAD:refs/for/master Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/iii), 528 bytes | 0 bytes/s, done. Total three (delta 0), reused 0 (delta 0) remote: Processing changes: updated: 1, done remote: remote: Updated Changes: remote: http://gerrithost/#/c/RecipeBook/+/702 Modify to a proper, yeast based pizza dough. remote: To ssh://gerrithost:29418/RecipeBook * [new branch] HEAD -> refs/for/master
Detect that the output of this control is slightly dissimilar from Max's offset commit. This fourth dimension, the output verifies that the modify was updated.
Having uploaded the reworked commit, Max can go back to the Gerrit web interface, look at his modify and diff the offset patch set with his rework in the 2d one. Once he has verified that the rework follows Hannahs recommendation he presses the Done button to let Hannah know that she can review the changes.
When Hannah side by side looks at Max's alter, she sees that he incorporated her feedback. The change looks good to her, so she changes her vote to a +two
.
Verifying the Change
Hannah's +2
vote ways that Max's change satisfies the Needs Review check. It has to pass one more check earlier it tin can be accepted: the Needs Verified bank check.
The Verified cheque means that the change was confirmed to piece of work. This blazon of check typically involves tasks such as checking that the lawmaking compiles, unit tests laissez passer, and other actions. Yous tin configure a Verified check to consist of as many or every bit few tasks equally needed.
Note | Recall that this walkthrough uses Gerrit's default workflow. Projects can add custom checks or fifty-fifty remove the Verified check entirely. |
Verification is typically an automated process using the Gerrit Trigger Jenkins Plugin or a similar mechanism. Withal, in that location are still times when a change requires manual verification, or a reviewer needs to cheque how or if a change works. To adapt these and other like circumstances, Gerrit exposes each change as a git branch. The Gerrit UI includes a download link in the Gerrit Code Review Screen to get in easy for reviewers to fetch a branch for a specific alter. To manually verify a change, a reviewer must accept the Verified permission. Then, the reviewer can fetch and checkout that branch from Gerrit. Hannah has this permission, so she is authorized to manually verify Max'due south change.
Note | The Verifier can be the aforementioned person equally the code reviewer or a different person entirely. |
Figure four. Verifying the Change
Unlike the code review cheque, the verify check is pass/fail. Hannah tin can provide a score of either +1
or -1
. A change must take at to the lowest degree 1 +1
and no -1
.
Hannah selects a +one
for her verified check. Max's change is now ready to be submitted.
Submitting the Modify
Max is now ready to submit his modify. He opens up the change in the Code Review screen and clicks the SUBMIT button.
At this point, Max'southward change is merged into the repository's master co-operative and becomes an accepted part of the project.
Next Steps
This walkthrough provided a quick overview of how a change moves through the default Gerrit workflow. At this point, you can:
-
Read the Users guide to get a improve sense of how to make changes using Gerrit
-
Review the Project Owners guide to learn more about configuring projects in Gerrit, including setting user permissions and configuring verification checks
-
Read through the Git and Gerrit training slides that explain concepts and workflows in item. They are meant for self-studying how Git and Gerrit work:
-
Git explained: Git Concepts and Workflows
-
Gerrit explained: Gerrit Concepts and Workflows
-
Source: https://gerrit-review.googlesource.com/Documentation/intro-gerrit-walkthrough.html
0 Response to "â€⢠Worked on Gerrit to Merge Changes to the Git Repository After Reviews Are Done"
Post a Comment