When I first met Gerrit in the company, I was stunned. What xx toys…..
Gerrit, an open source code review software, uses a web interface. With web browsers, software developers on the same team can review each other’s code changes and decide whether they can submit, roll back, or continue to modify. It uses Git, the version control system, as the underlying layer.
It’s a spin-off from Rietveld, written by Google’s Shawn Pearce, and was originally created to manage the Android project. [2] The name of the software comes from Dutch designer Gerrit Rietveld.
— — — — — from the wiki
Then the company also used GitLab at the same time, I was confused. Normally, GitLab is enough for most everyday use, so why use Gerrit anyway?
It’s a spin-off from Rietveld, written by Google’s Shawn Pearce, and was originally created to manage the Android project. [2] The name of the software comes from Dutch designer Gerrit Rietveld.
=== GitLab wiki
Later I learned the relationship and role between them, similar to the picture below
The role of GitLab account given by the company is Reporter, which can only pull but not push. If you want to push code to the branch, you can only push it to Gerrit first. Gerrit may have code plug-ins or manual review, and then push it successfully. There is synchronization between Gerrit and GitLab, so you can see your push code in GitLab in real time.
Using Gerrit places a hook script in.git/hooks of your project,
There are various hook scripts that will be executed at certain times as long as you remove the suffix. Sample.
Gerrit uses one of these scripts to add a random value of change-id to your commit comment
At commit time in Idea, if hook scripts exist in your project, the option to execute hook scripts will appear
We try to compile once before commit, because sometimes the code pushed to the remote repository may not compile properly (pushing the code that doesn’t work or even compile properly can really affect other colleagues’ development).
In pre-commit, we add the following command, since my project is multi-module, we also need to enter the POM file in the specific sub-module. Git is executed in the same layer as the.git directory
And then COMMIT
You can actually compile once before committing. This commit will be prevented if hooks return non-zero
Another aspect of using Gerrit is that you cannot push directly to the original remote branch
#A push would bypass Gerrit's code review, so it would not succeed
git push origin master
#This is the way
git push origin head:refs/for/master
Copy the code
Using GitLab directly (without Gerrit cooperation), the interface is very beautiful and easy to use, and it also meets the requirements of the previous code review. So let’s all go to GitLab, too.
www.cnblogs.com/kevingrace/…
zh.wikipedia.org/wiki/GitLab
zh.wikipedia.org/wiki/Gerrit