How to add one more custom Labels to accumulate votes along with 'Code-Review' label

41 views
Skip to first unread message

selvam vasu

unread,
Apr 10, 2017, 10:14:10 AM4/10/17
to Repo and Gerrit Discussion
Hi,
I am a newbie to Gerrit. In my project, I have two labels 'Code-Review' and 'Design-Review'. I would like to write custom rules.pl to accumulate votes for each Labels. If each label gets 3 points, then the author can submit the changes.

my rules.pl is,

sum_list([], 0).
sum_list([H | Rest], Sum) :- sum_list(Rest,Tmp), Sum is H + Tmp.

first_list([], _).
first_list([F], F).
first_list([F | Rest], F).

score(Category, Score, User) :-
  gerrit:commit_label(label(Category, Score), User).

add_category_min_score(In, Category, Min,  P) :-
  findall(Score, score(Category, Score, User), Scores),
  findall(User, score(Category, Score, User), Users),
  sum_list(Scores, Sum),
  Sum >= Min, !,
  first_list(Users, FirstUser),
  P = [label(Category, ok(FirstUser)) | In].

add_category_min_score(In, Category, Min, P) :-
  P = [label(Category, need(Min)) | In].

submit_rule(S) :-
  gerrit:default_submit(X),
  X =.. [submit | Ls],
  gerrit:remove_label(Ls, label('Code-Review', _), NoCR),
  add_category_min_score(NoCR, 'Code-Review', 3, Labels),
  S =.. [submit | Labels].

 Let me know where I have to add my one more custom label 'Design-Review' to check that voting accumulation for submitting.

Also, How can I add a rule that author only can submit the changes, other than registered users and some group users.  Does it need to be configured in ACL or rules.pl?
In ACL, I didn't see any configs related to submitting changes by author only.   Please shed some lights in this. 

selvam vasu

unread,
Apr 20, 2017, 10:52:04 AM4/20/17
to Repo and Gerrit Discussion
Reply all
Reply to author
Forward
0 new messages