Gerrit 服务器如何拦截提交。寻找技术细节

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

我知道 Gerrit 收到 git 提交(可能使用 update 钩子),并将它们写在某个地方的假 ref 上,直到同行评审完成,但这个过程到底是如何工作的在技​​术实施方面?涉及哪些 Git 命令?

您可能会引用用户 when pushing new commits.

使用的魔术参考 refs/for/<branch ref>

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://john.doe@git.example.com: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.


从技术上讲,这是由 cmd-receive-pack 管理的。

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

gerrit/sshd/commands/Receive.java, which receives change upload over SSH using the Git receive-pack protocol实现。