Gerrit All-projects submit_filter

394 views
Skip to first unread message

Ritesh Prajapati

unread,
Apr 13, 2016, 8:44:00 AM4/13/16
to Repo and Gerrit Discussion
Hello,

I have below config in rules.pl under "All-Projects" for Non-author-code review.  Now, I need exception for specific project where author can review code.  Is there any solution to implement this scenario ? Any  submit_rule we can use in child project which can over-ride submit_filter ?

All-projects rules.pl :

submit_filter(In, Out) :-

    In =.. [submit | Ls],

    add_non_author_approval(Ls, R),

    Out =.. [submit | R].

 

add_non_author_approval(S1, S2) :-

    gerrit:commit_author(A),

    gerrit:commit_label(label('Code-Review', 2), R),

    R \= A, !,

    S2 = [label('Non-Author-Code-Review', ok(R)) | S1].

add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).


Thanks,
Ritesh

Edwin Kempin

unread,
Apr 13, 2016, 8:48:32 AM4/13/16
to Ritesh Prajapati, Repo and Gerrit Discussion
On Wed, Apr 13, 2016 at 2:40 PM, Ritesh Prajapati <rites...@gmail.com> wrote:
Hello,

I have below config in rules.pl under "All-Projects" for Non-author-code review.  Now, I need exception for specific project where author can review code.  Is there any solution to implement this scenario ? Any  submit_rule we can use in child project which can over-ride submit_filter ?
You may introduce another level in your project hierarchy.
E.g. have a Default-Settings project under the All-Projects project. Then install your submit filter for the Default-Settings project and let all projects inherit from it, except the project for which you need an exception. Let this project inherit from All-Projects directly.
 

All-projects rules.pl :

submit_filter(In, Out) :-

    In =.. [submit | Ls],

    add_non_author_approval(Ls, R),

    Out =.. [submit | R].

 

add_non_author_approval(S1, S2) :-

    gerrit:commit_author(A),

    gerrit:commit_label(label('Code-Review', 2), R),

    R \= A, !,

    S2 = [label('Non-Author-Code-Review', ok(R)) | S1].

add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).


Thanks,
Ritesh

--
--
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.


Ritesh Prajapati

unread,
Apr 13, 2016, 8:56:48 AM4/13/16
to Repo and Gerrit Discussion, rites...@gmail.com

Thanks Edwin for your help!!

Appreciated your prompt response!!

Yes, I can do that. But problem is I have 100+ projects which are already using "All-projects" as parent and need "non-author-code-review". So  If I add another level in project hierarchy, then I will need to change parent for 100+ projects.

Regards,
Ritesh

Edwin Kempin

unread,
Apr 13, 2016, 9:00:44 AM4/13/16
to Ritesh Prajapati, Repo and Gerrit Discussion
On Wed, Apr 13, 2016 at 2:56 PM, Ritesh Prajapati <rites...@gmail.com> wrote:

Thanks Edwin for your help!!

Appreciated your prompt response!!

Yes, I can do that. But problem is I have 100+ projects which are already using "All-projects" as parent and need "non-author-code-review". So  If I add another level in project hierarchy, then I will need to change parent for 100+ projects.
Sure, but you could do this with one command. This could be done by the set-project-parent command with the --children-of option [1].

Ritesh Prajapati

unread,
Apr 13, 2016, 9:16:50 AM4/13/16
to Repo and Gerrit Discussion, rites...@gmail.com
  Thanks a lot Edwin!!

  I will try this.

  Best Regards,
  Ritesh

Saša Živkov

unread,
Apr 13, 2016, 9:32:31 AM4/13/16
to Ritesh Prajapati, Repo and Gerrit Discussion
On Wed, Apr 13, 2016 at 2:40 PM, Ritesh Prajapati <rites...@gmail.com> wrote:
Hello,

I have below config in rules.pl under "All-Projects" for Non-author-code review.  Now, I need exception for specific project where author can review code.  Is there any solution to implement this scenario ? Any  submit_rule we can use in child project which can over-ride submit_filter ?

submit_rule cannot override a submit_filter in a parent project... now without the submit_filter cooperating on that.

A relatively simple solution would be to add a list of exceptions in this submit_filter, like:

exception(project_name_1).
exception(another_project).

and then exclude those projects from your filter:


All-projects rules.pl :

submit_filter(In, In) :-
  gerrit:change_project(P),
  exception(P),
  !.
 

submit_filter(In, Out) :-

    In =.. [submit | Ls],

    add_non_author_approval(Ls, R),

    Out =.. [submit | R].

 

add_non_author_approval(S1, S2) :-

    gerrit:commit_author(A),

    gerrit:commit_label(label('Code-Review', 2), R),

    R \= A, !,

    S2 = [label('Non-Author-Code-Review', ok(R)) | S1].

add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).


Thanks,
Ritesh

--

Ritesh Prajapati

unread,
Apr 14, 2016, 7:29:42 AM4/14/16
to Repo and Gerrit Discussion, rites...@gmail.com
  
Hello Zivkov,

Thanks for your help!

Actually I'm not much familiar with prolog. Could you please help me to prepare rules.pl ?  Would it look like as shown below ?


=========================== All-projects rules.pl : =================================
exception(project_name_1).
exception(another_project).

submit_filter(In, In) :-
  gerrit:change_project(P),
  exception(P),
  !.
 

submit_filter(In, Out) :-

    In =.. [submit | Ls],

    add_non_author_approval(Ls, R),

    Out =.. [submit | R].

 

add_non_author_approval(S1, S2) :-

    gerrit:commit_author(A),

    gerrit:commit_label(label('Code-Review', 2), R),

    R \= A, !,

    S2 = [label('Non-Author-Code-Review', ok(R)) | S1].

add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).


==================================  End rules.pl ==========================================

Saša Živkov

unread,
Apr 14, 2016, 8:56:15 AM4/14/16
to Ritesh Prajapati, Repo and Gerrit Discussion
On Thu, Apr 14, 2016 at 1:29 PM, Ritesh Prajapati <rites...@gmail.com> wrote:
  
Hello Zivkov,

Thanks for your help!

Actually I'm not much familiar with prolog. Could you please help me to prepare rules.pl ?  Would it look like as shown below ?

Yes.

Ritesh Prajapati

unread,
Apr 16, 2016, 9:22:35 AM4/16/16
to Repo and Gerrit Discussion, rites...@gmail.com
  Hi Zivkov, below rules.pl is not working.

 Thanks,
 Ritesh

Saša Živkov

unread,
Apr 18, 2016, 11:15:33 AM4/18/16
to Ritesh Prajapati, Repo and Gerrit Discussion
On Sat, Apr 16, 2016 at 3:22 PM, Ritesh Prajapati <rites...@gmail.com> wrote:
  Hi Zivkov, below rules.pl is not working.

 
What exactly doesn't work? The exception case or the general case?

The below rules.pl cannot work as-is.
You have to specify concrete project name exceptions.
Can you post your rules.pl here and describe which scenario doesn't work?

Ritesh Prajapati

unread,
Apr 22, 2016, 1:10:25 PM4/22/16
to Repo and Gerrit Discussion, rites...@gmail.com

   Non-author-code-review itself is not working. Even, general case is not working. I had used concrete project names.
   
   Here is my rules.pl
 
=========================== All-projects rules.pl : =================================
exception(test-project).

submit_filter(In, In) :-
  gerrit:change_project(P),
  exception(P),
  !.
 

submit_filter(In, Out) :-

    In =.. [submit | Ls],

    add_non_author_approval(Ls, R),

    Out =.. [submit | R].

 

add_non_author_approval(S1, S2) :-

    gerrit:commit_author(A),

    gerrit:commit_label(label('Code-Review', 2), R),

    R \= A, !,

    S2 = [label('Non-Author-Code-Review', ok(R)) | S1].

add_non_author_approval(S1, [label('Non-Author-Code-Review', need(_)) | S1]).

==================================  End rules.pl ==========================================


Reply all
Reply to author
Forward
0 new messages