ich this answer auf die Frage gestellt, die Sie verbunden ist, aber Es kann Sie in die richtige Richtung führen:
Ich schrieb diesen Prolog-Filter für unsere Gerrit-Installation. Ich habe es als ein submit_filter im übergeordneten Projekt getan, weil ich wollte, dass es für alle Projekte in unserem System gilt.
%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).
Die Vorteile (IMO) von dieser Regel über rule #8 from the cookbook sind:
- Das
Self-Reviewed
Label wird nur dann angezeigt, wenn die die Änderung blockiert wird, anstatt das Hinzufügen eines Non-Author-Code-Review
Label jede Änderung
- Durch
reject(O)
der Regel unter Verwendung bewirkt, dass die Self-Reviewed
Label buchstäblich eine rote Fahne
- Alsseinanstelle eines
submit_rule
wird diese Regel in einem übergeordneten Projekt installiert und gilt für alle Teilprojekte
Bitte beachten Sie: Diese Regel verfasst wird, um die Owner
von Selbst Überprüfung einer Änderung, während das Beispiel zu verhindern, aus dem Kochbuch vergleicht gegen die Author
. Je nach Ihrem Workflow, mögen Sie vielleicht die 2 gerrit:change_owner(O)
Prädikate mit gerrit:commit_author(O)
oder gerrit:commit_committer(O)
Ich habe Gerrit nicht mit Git eingerichtet. Ich habe diesen Leitfaden mehr oder weniger verfolgt [https://www.digitalcean.com/community/tutorials/how-to-install-gerrit-on-an-ubuntu-cloud-server]. Wo finde ich rules.pl in diesem Fall? Wo würde rules.pl in diesem Fall gehen? – Harshdeep