| submit_filter(In, Out) :- |
| In =.. [submit | L1], |
| only_author_can_submit(L1, L2), |
| non_author_code_review(L2, L3), |
| Out =.. [submit | L3]. |
| |
| %% CLs authored by non-Google developers can be submitted by others. |
| only_author_can_submit(S, S) :- |
| gerrit:commit_author(_, _, Email), |
| \+ regex_matches('@google.com', Email), |
| !. |
| |
| %% The Admin Bot (User ID: 6165) can submit on behalf of others. |
| only_author_can_submit(S, S) :- |
| gerrit:current_user(Id), |
| Id == user(6165), |
| !. |
| |
| only_author_can_submit(S, S) :- |
| gerrit:commit_author(Id), |
| gerrit:current_user(Id), |
| !. |
| |
| only_author_can_submit(S, [label('Patchset-Author', need(_)) | S]). |
| |
| non_author_code_review(S1, S2) :- |
| gerrit:commit_author(A), |
| gerrit:commit_label(label('Code-Review', 2), R), |
| R \= A, !, |
| S2 = [label('Non-Author-Code-Review', ok(R)) | S1]. |
| |
| non_author_code_review(S, [label('Non-Author-Code-Review', need(_)) | S]). |