Documentation: Add prolog submit-rule example Submit by Author

Issue 1631 has been filed to track the need of a way to query
if a certain user has Submit permissions.

Bug: Issue 891
Change-Id: I6f78343012fb0bbcdc7ed90fde1b4189dfcd28c7
This commit is contained in:
Johan Björk 2012-10-26 10:16:07 -04:00
parent 44291678e0
commit 0f13254156

View File

@ -721,6 +721,30 @@ review by the associated `master`.
add_apprentice_master(S, S).
====
Example 14: Only allow Author to submit change
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This example adds a new needed category `Patchset-Author` for any user that is
not the author of the patch. This effectively blocks all users except the author
from submitting the change. This could result in an impossible situation if the
author does not have permissions for submitting the change.
.rules.pl
[caption=""]
====
submit_rule(S) :-
gerrit:default_submit(In),
In =.. [submit | Ls],
only_allow_author_to_submit(Ls, R),
S =.. [submit | R].
only_allow_author_to_submit(S, S) :-
gerrit:commit_author(Id),
gerrit:current_user(Id),
!.
only_allow_author_to_submit(S1, [label('Patchset-Author', need(_)) | S1]).
====
GERRIT
------
Part of link:index.html[Gerrit Code Review]