rules.pl: Unabale to revoke votes

54 views
Skip to first unread message

Björn Pedersen

unread,
Feb 17, 2015, 5:29:08 AM2/17/15
to repo-d...@googlegroups.com
Hi,

with the following rules.pl:

submit_rule(S) :-
        gerrit:default_submit(X),
        X =.. [submit | Ls],
        add_non_author_approval(Ls, R1),
        trivjenkins(R1,R),
        S =.. [submit | R].

add_non_author_approval(S1, S2) :-
        gerrit:commit_author(A), gerrit:commit_label(label('Code-Review', 2), R),
        A == R
        , !,
        S2 = [label('Non-Author-Code-Review', ok(R)) | S1].
        add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).



trivjenkins(S1,S2):-
        gerrit:commit_label(label('Verified', 1), user(1000000)),
        gerrit:commit_stats(B1,B2,B3),
        (B2 < 5 ;gerrit:commit_message_matches('^\\[TRIVIAL\\]')), !,
        S2 = [label('TrivialJenkins', ok(user(1000000)))].
        trivjenkins(S1, [label('TrivialJenkins', may(_)) | S1]).

I get the desired behaviour of being able to submit trivial changes without non-author code review (well, for testing I actually require author-review) if user 1000000  (me in this case) approves the change.

But in the web interface, once the Verified label is set, I only the that TrivialJenkins has been given, but I can not revoke the Verified or Code-Review label anymore (see screenshot).

Any ideas what I am doing wrong here?

Björn

screen2.png

Saša Živkov

unread,
Feb 17, 2015, 7:47:27 AM2/17/15
to Björn Pedersen, repo-d...@googlegroups.com
On Tue, Feb 17, 2015 at 11:29 AM, Björn Pedersen <ice...@googlemail.com> wrote:
Hi,

with the following rules.pl:

submit_rule(S) :-
        gerrit:default_submit(X),
        X =.. [submit | Ls],
        add_non_author_approval(Ls, R1),
        trivjenkins(R1,R),
        S =.. [submit | R].

add_non_author_approval(S1, S2) :-
        gerrit:commit_author(A), gerrit:commit_label(label('Code-Review', 2), R),
        A == R
 
Shouldn't this be A \= R ? You are checking if there is a non-author approval.
 
        , !,
        S2 = [label('Non-Author-Code-Review', ok(R)) | S1].
        add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).



trivjenkins(S1,S2):-
        gerrit:commit_label(label('Verified', 1), user(1000000)),
        gerrit:commit_stats(B1,B2,B3),
        (B2 < 5 ;gerrit:commit_message_matches('^\\[TRIVIAL\\]')), !,
        S2 = [label('TrivialJenkins', ok(user(1000000)))].
        trivjenkins(S1, [label('TrivialJenkins', may(_)) | S1]).

I get the desired behaviour of being able to submit trivial changes without non-author code review (well, for testing I actually require author-review) if user 1000000  (me in this case) approves the change.

But in the web interface, once the Verified label is set, I only the that TrivialJenkins has been given, but I can not revoke the Verified or Code-Review label anymore (see screenshot).

I am not sure I understand what you want but you must remove the Verified label from the result of the submit_rule(S)
if you want to remove it from this change.



Any ideas what I am doing wrong here?

Björn

--
--
To unsubscribe, email repo-discuss...@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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Björn Pedersen

unread,
Feb 18, 2015, 3:06:10 AM2/18/15
to repo-d...@googlegroups.com, ice...@googlemail.com


Am Dienstag, 17. Februar 2015 13:47:27 UTC+1 schrieb zivkov:


 
Shouldn't this be A \= R ? You are checking if there is a non-author approval.

Yes, this is on purpose in my test project where I am the only user.
 
I am not sure I understand what you want but you must remove the Verified label from the result of the submit_rule(S)
if you want to remove it from this change.

Now I found the problem. I should use two submit rules, see below and cookbook example no.5.
I was more or less removing the default rules if TrivialJenkins matched, because I did not add the '| S1' in the result. But adding it
added the non-author requirement as well in my previous version.

 
submit_rule(S) :-
        gerrit:default_submit(X),
        X =.. [submit | Ls],
        add_non_author_approval(Ls, R),

        S =.. [submit | R].

add_non_author_approval(S1, S2) :-
        gerrit:commit_author(A), gerrit:commit_label(label('Code-Review', 2), R),
        A == R
        , !,
        S2 = [label('Non-Author-Code-Review', ok(R)) | S1].
        add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).


submit_rule(S) :-
        gerrit:default_submit(X),
        X =.. [submit | Ls],
        trivjenkins(Ls, R),

        S =.. [submit | R].

trivjenkins(S1,S2):-
        gerrit:commit_label(label('Verified', 1), user(1000000)),
        gerrit:commit_stats(B1,B2,B3),
        (B2 < 5 ;gerrit:commit_message_matches('^\\[TRIVIAL\\]')), !,
        S2 = [label('TrivialJenkins', ok(user(1000000)) ) | S1].

        trivjenkins(S1, [label('TrivialJenkins', may(_)) | S1]).

Björn
Reply all
Reply to author
Forward
0 new messages