napisałem this answer na pytanie, które związane, ale może to prowadzić Cię w dobrym kierunku:
napisałem ten prolog filtr dla naszej instalacji Gerrit. Zrobiłem to jako filter_filter w projekcie nadrzędnym, ponieważ chciałem, aby było ono stosowane do wszystkich projektów w naszym systemie.
%filter to require all projects to have a code-reviewer other than the owner
submit_filter(In, Out) :-
%unpack the submit rule into a list of code reviews
In =.. [submit | Ls],
%add the non-owner code review requiremet
reject_self_review(Ls, R),
%pack the list back up and return it (kinda)
Out =.. [submit | R].
reject_self_review(S1, S2) :-
%set O to be the change owner
gerrit:change_owner(O),
%find a +2 code review, if it exists, and set R to be the reviewer
gerrit:commit_label(label('Code-Review', 2), R),
%if there is a +2 review from someone other than the owner, then the filter has no work to do, assign S2 to S1
R \= O, !,
%the cut (!) predicate prevents further rules from being consulted
S2 = S1.
reject_self_review(S1, S2) :-
%set O to be the change owner
gerrit:change_owner(O),
find a +2 code review, if it exists, and set R to be the reviewer
gerrit:commit_label(label('Code-Review', 2), R),
R = O, !,
%if there isn't a +2 from someone else (above rule), and there is a +2 from the owner, reject with a self-reviewed label
S2 = [label('Self-Reviewed', reject(O))|S1].
%if the above two rules didn't make it to the ! predicate, there aren't any +2s so let the default rules through unfiltered
reject_self_review(S1, S1).
świadczeń (IMO) od tej reguły nad rule #8 from the cookbook są:
Self-Reviewed
etykieta jest widoczna tylko wtedy, gdy zmiana jest blokowany, zamiast dodawania Non-Author-Code-Review
wytwórnię do każdy zmian
- korzystając
reject(O)
reguła powoduje etykietę Self-Reviewed
dosłownie być czerwona flaga
- Jako
submit_filter
zamiast submit_rule
, zasada ta jest zainstalowany w projekcie dominującej i odnosi się do wszystkich podprojektów
Uwaga: Zasada ta jest autorstwa zapobiec Owner
od samodzielnego przeglądu zmian, podczas gdy przykładowo z książki kucharskiej porównuje się z Author
. W zależności od przepływu pracy, można wymienić 2 gerrit:change_owner(O)
predykatów z gerrit:commit_author(O)
lub gerrit:commit_committer(O)