问题
We are planning to have some policies that will ensure we don't accept commits that won't adhere to commit message policy. This policy is specific to a repo.
Is it possible to run pre-receive style hooks in Gerrit where we can run these policies before the patch gets created?
回答1:
Yes, Gerrit has its own hook mechanism included via the hooks plugin so it's possible to block the push if some policy is not valid.
Consider also to use the Git::Hooks. We use it and it's really good. Using Git::Hooks you can implement a better strategy to manage these checks:
1) Accept the commit (patchset is created)
2) Execute the policy checks
3) Vote in the review (approving or blocking the change)
来源:https://stackoverflow.com/questions/44680993/is-it-possible-to-run-a-pre-receive-style-hooks-in-gerrit