我想创建以下规则:
我的规则是:
% rule : 1+1+1=2 Code-Review
% rationale : introduce accumulative voting to determine if a change
% is submittable or not and make the change submittable
% if the total score is 3 or higher.
sum_list([], 0).
sum_list([H | Rest], Sum) :- sum_list(Rest,Tmp), Sum is H + Tmp.
add_category_min_score(In, Category, Min, P) :-
findall(X, gerrit:commit_label(label(Category,X),R),Z),
sum_list(Z, Sum),
Sum >= Min, !,
gerrit:commit_label(label(Category, V), U),
V >= 1,
!,
P = [label(Category,ok(U)) | 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].
此规则根本不起作用,问题在于+2投票。 我怎样才能按照自己的意愿重新制定这条规则?
答案 0 :(得分:0)
因此,您希望至少有3位评论者可以添加+1和+2。
如果您删除了开发人员的权利,可以从项目配置中获得+2的收益,并使用经过少量修改的prolog食谱示例13呢?
submit_rule(submit(CR)) :-
sum(3, 'Code-Review', CR),
% gerrit:max_with_block(-1, 1, 'Verified', V).
% Sum the votes in a category. Uses a helper function score/2
% to select out only the score values the given category.
sum(VotesNeeded, Category, label(Category, ok(_))) :-
findall(Score, score(Category, Score), All),
sum_list(All, Sum),
Sum >= VotesNeeded,
!.
sum(VotesNeeded, Category, label(Category, need(VotesNeeded))).
score(Category, Score) :-
gerrit:commit_label(label(Category, Score), User).
% Simple Prolog routine to sum a list of integers.
sum_list(List, Sum) :- sum_list(List, 0, Sum).
sum_list([X|T], Y, S) :- Z is X + Y, sum_list(T, Z, S).
sum_list([], S, S).