Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude author from gerrit review

Tags:

gerrit

prolog

I want to disallow the author of a change to review his/her own changes in gerrit. 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 prolog.

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.

like image 620
Bananeweizen Avatar asked Jul 19 '12 12:07

Bananeweizen


People also ask

How do I change my Gerrit ownership?

You need to have "Administrate Server" rights. Go to: Projects > List > All-Projects or a specific project > Access > Edit and add permissions.

How do I add default reviewers to Gerrit?

The default reviewers can be configured in the Gerrit Web UI under Projects > List > <your project> > General in the reviewers Plugin section. The reviewers-by-blame plugin can automatically add reviewers to changes based on the git blame computation on the changed files.

What does rebase mean in Gerrit?

Rebase a Change. Move a Change. Abandon/Restore a Change. Cherry-Pick changes of a Change. Using Topics.


2 Answers

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.

like image 159
very Avatar answered Oct 02 '22 17:10

very


I'm not sure that this what you are looking for but it might give you some inspiration. According to this discussion the following fragment approves changes only if the reviewer and the change owner are not the same person.

  % If a reviewer approved the change, its OK.
  submit_rule(submit(CR)) :-
    change_owner(Owner),
    max_with_block('Code-Review', -2, 2, ok(Reviewer)),
    not_same(Owner, Reviewer),
    CR = label('Code-Review', ok(Reviewer)),
    !.
like image 41
Alexander Serebrenik Avatar answered Oct 02 '22 16:10

Alexander Serebrenik