prolog submit rule -- Non Author Code Review with optional verification

340 views
Skip to first unread message

euphxenos

unread,
Aug 17, 2016, 12:30:15 PM8/17/16
to Repo and Gerrit Discussion
We're already using the prolog submit rule straight out of Gerrit's prolog submit rules cookbook (example 8) to require a non-author code review for submits.  We're getting ready to make our verification process much more stringent, so we'd like to make verification optional to give people a transitional period where they can still see whether or not their changes are passing or failing verification in Gerrit's UI, but without preventing them from submitting (part of what we need to do is to shake out the problems in the new verification process).  It differs from example 10 in the cookbook because we want to keep the Verified label in the UI, not drop it completely.  What I've come up with so far is this:

submit_rule(submit(CR, V)) :-
    base(CR, V),
    CR = label(_, ok(Reviewer)),
    gerrit:commit_author(Author),
    Author \= Reviewer,
    !.

submit_rule(submit(CR, V, N)) :-
    base(CR, V),
    N = label('Non-Author-Code-Review', need(_)).

base(CR, V) :-
    gerrit:max_with_block(-2, 2, 'Code-Review', CR),
    label('Verified', may(_)).

This is almost exactly example 8 without using gerrit:default_submit, except I've changed the last line to use may(_) on the Verified label.  The problem I'm having with this is that while it does make Verified optional and keep it in the UI (I can submit a change with a +2 review, regardless of the state of the verified label), now the Non Author Code Review label isn't working properly.  When a non-author gives a review, that column is no longer checked in the UI.  We're using Gerrit 2.12.  What am I doing wrong?

Kenny Ho

unread,
Aug 18, 2016, 1:16:21 PM8/18/16
to Repo and Gerrit Discussion
If I read this correctly, wouldn't the second submit_rule() not evaluated when Author not equal Reviewiew because of the ! that cut out early?  I think you might need a N = label('Non-Author-Code-Review', ok(Reviewer)) for the first submit_rule()?

Kenny

Bassem Rabil

unread,
Aug 18, 2016, 1:32:34 PM8/18/16
to Repo and Gerrit Discussion
You can accomplish this by native Gerrit permissions by blocking Code-Review -2..+2 for a builtin group called "Change Owner". For more details check this discussion thread [1]. I would prefer to use native permissions than prolog to avoid prolog complexity and the backward compatibility. Also there was an issue with the example prolog that was fixed by Sasa [2], [3].



Regards
Bassem

Saša Živkov

unread,
Aug 22, 2016, 11:52:39 AM8/22/16
to euphxenos, Repo and Gerrit Discussion
On Wed, Aug 17, 2016 at 6:30 PM, euphxenos <euph...@gmail.com> wrote:
We're already using the prolog submit rule straight out of Gerrit's prolog submit rules cookbook (example 8) to require a non-author code review for submits.  We're getting ready to make our verification process much more stringent, so we'd like to make verification optional to give people a transitional period where they can still see whether or not their changes are passing or failing verification in Gerrit's UI, but without preventing them from submitting

The simplest way for achieving that is to set the "function" property of the Verified label to NoOp as documented in [1].
In that case the Verified label is purely informational and doesn't prevent submit.

 
(part of what we need to do is to shake out the problems in the new verification process).  It differs from example 10 in the cookbook because we want to keep the Verified label in the UI, not drop it completely.  What I've come up with so far is this:

submit_rule(submit(CR, V)) :-
    base(CR, V),
    CR = label(_, ok(Reviewer)),
    gerrit:commit_author(Author),
    Author \= Reviewer,
    !.

submit_rule(submit(CR, V, N)) :-
    base(CR, V),
    N = label('Non-Author-Code-Review', need(_)).

base(CR, V) :-
    gerrit:max_with_block(-2, 2, 'Code-Review', CR),
    label('Verified', may(_)).

This is almost exactly example 8 without using gerrit:default_submit, except I've changed the last line to use may(_) on the Verified label.  The problem I'm having with this is that while it does make Verified optional and keep it in the UI (I can submit a change with a +2 review, regardless of the state of the verified label), now the Non Author Code Review label isn't working properly.  When a non-author gives a review, that column is no longer checked in the UI.  We're using Gerrit 2.12.  What am I doing wrong?

--
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages