| Issue 2469: | Rule 1+1=2 from Documentation does not work | |
| 5 people starred this issue and may be notified of changes. | Back to list |
************************************************************ ***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW ***** ***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL ***** ***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC. ***** ***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS! ***** ************************************************************ Affected Version: What steps will reproduce the problem? 1. Setup rules.pl from https://gerrit-documentation.storage.googleapis.com/Documentation/2.8.1/prolog-cookbook.html#_example_13_1_1_2_code_review (both two does not work) 2. Let two people Review change with +1 flag What is the expected output? What do you see instead? It is expected that the rule for Code-Review will be met (The change will be in status Ready to Submit) Instead the change is still in status "review in progress". Please provide any additional information below. If you test the rule using "gerrit test-submit rule ..." the result of review is something like: [ { "status": "OK", "ok": { "Code-Review": {} } } ] And that is not enough to Gerrit set changeset as "Ready to Submit". After some investigation I have found that the output of the rule must be something like to Gerrit set changeset as "Ready to Submit": [ { "status": "OK", "ok": { "Code-Review": { "_account_id": 1000060, "name": "Jakub Štiller", "email": "jakub.stiller@gmail.com", "username": "jakub.stiller", "avatars": [] } } } ] To accomplish this I have to change the rule to: 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(Category, Min, P) :- findall(S, score(Category, S, U), SList), findall(U, score(Category, S, U), UList), sum_list(SList, Sum), Sum >= Min, !, first_list(UList, FU), P = label(Category, ok(FU)). add_category_min_score(Category, Min, P) :- P = label(Category, need(Min)). submit_filter(submit(CR)) :- add_category_min_score('Code-Review', 2, CR), See implicit set first found user into ok(..) function.
Feb 13, 2014
#1
jakub.st...@gmail.com
Jul 21, 2014
Here is a complete rules.pl file that works on Gerrit 2.8, based on the workaround above:
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', 2, Labels),
S =.. [submit | Labels].
Jul 26, 2014
First of all, yes, your updated rules.pl seems to fix our problem. It is indeed required that Code-Review requires an ok with a user. But I'm wondering why it started to be a problem in our case when we upgraded to Gerrit 2.9. With 2.8.x up to 2.8.6.1 we haven't had this problem.
Apr 9, 2015
Issue 3284 has been merged into this issue. |
|
| ► Sign in to add a comment |