Search code examples
prologgerrit

Exclude author from gerrit review


I want to disallow the author of a change to review his/her own changes in . I'm aware of this suggested hack, but that doesn't really solve the issue.

Now I learned from the gerrit issues that gerrit's hardcoded rules can be modified by custom prolog code, so it should potentially be possible to modify the workflow as I want. However, I have never modified gerrit's workflow before and I don't know much .

Does anyone have a small working example of custom rules for gerrit using this prolog engine?

I will happily accept other alternatives of how to forbid authors doing a self-review, given they do not require my team to change the current workflow.


Solution

  • I found a very easy answer in this google group: groups.google.com/disable-self-review

    In a parent project (default is the All-Projects project) add this to the project.config file in refs/meta/config branch:

    [access "refs/*"]
    label-Code-Review = block -2..+2 group Change Owner
    

    and in the groups file in the same branch add this line

    global:Change-Owner Change Owner
    

    Then take the statement that allows the right into the child project's project.config:

    label-Code-Review = -2..+2 group Developers
    

    Make sure to do write the block statement in the parent project and give the rights in the child project. If allow and block are in the same file the allow will overrule (See this). This will block the owner of a change to give -2 or +2. It will leave the -1 and +1 options intact. You can add a similar statement for any other custom labels you might use.