Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the Gerrit server intercept commits. Looking for technical details

Tags:

git

server

gerrit

I understand that Gerrit receives git commits (using the update hook perhaps), and write them on a fake ref somewhere until the peer review is done, but how exactly does that process work in terms of the technical implementation? And what Git commands are involved?

like image 503
Sthe Avatar asked Oct 11 '16 07:10

Sthe


People also ask

How does Gerrit code review work?

Gerrit is a web-based code review tool, which is integrated with Git and built on top of Git version control system (helps developers to work together and maintain the history of their work). It allows merging changes to Git repository when you are done with the code reviews.

How do I verify my Gerrit code?

The Gerrit UI includes a download link in the Gerrit Code Review Screen to make it easy for reviewers to fetch a branch for a specific change. To manually verify a change, a reviewer must have the Verified permission. Then, the reviewer can fetch and checkout that branch from Gerrit.


1 Answers

You might reference the magic reference refs/for/<branch ref> which is used by user when pushing new commits.

To create new changes for review, simply push to the project’s magical refs/for/'branch' ref using any Git client tool:

git push ssh://sshusername@hostname:29418/projectname HEAD:refs/for/branch

E.g. john.doe can use git push to upload new changes for the experimental branch of project kernel/common, hosted at the git.example.com Gerrit server:

git push ssh://[email protected]:29418/kernel/common HEAD:refs/for/experimental

Each new commit uploaded by the git push client will be converted into a change record on the server.
The remote ref refs/for/experimental is not actually created by Gerrit, even though the client’s status messages may say otherwise.


Technically, this is managed by the cmd-receive-pack.

Invoked by 'git push' and updates the project's repository with the information fed from the 'git push' end.

It is implemented by gerrit/sshd/commands/Receive.java, which receives change upload over SSH using the Git receive-pack protocol.

like image 78
VonC Avatar answered Oct 05 '22 14:10

VonC