he publicado this answer a la pregunta que se ha vinculado a, pero puede conducirlo en la dirección correcta:
Escribí este filtro de prólogo para nuestra instalación de Gerrit. Lo hice como un submit_filter en el proyecto principal porque quería que se aplicara a todos los proyectos en nuestro sistema.
%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).
Los beneficios (IMO) de esta regla sobre rule #8 from the cookbook son:
- La etiqueta
Self-Reviewed
sólo se muestra cuando el cambio está siendo bloqueado, en lugar de añadir una etiqueta Non-Author-Code-Review
-cada cambio
- mediante el uso de
reject(O)
la regla hace que la etiqueta Self-Reviewed
a ser, literalmente, una bandera roja
- Como
submit_filter
en lugar de un submit_rule
, esta regla se instala en un proyecto principal y se aplica a todos los sub-proyectos
Por favor, tenga en cuenta: Esta regla es de autoría para evitar que el Owner
de auto-revisión de un cambio, mientras que el ejemplo del libro de cocina se compara con el Author
. Dependiendo de su flujo de trabajo, es posible que desee reemplazar los 2 gerrit:change_owner(O)
predicados con gerrit:commit_author(O)
o gerrit:commit_committer(O)