summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Björk <jbjoerk@gmail.com>2012-10-26 10:16:07 -0400
committerJohan Björk <jbjoerk@gmail.com>2012-10-30 09:15:59 -0400
commit0f13254156adf367daad830e4248fb15c644fe78 (patch)
tree8c008946f6610e95d239c9c22ccdcd3b7c677e9a
parent44291678e02d99b5b8bb99d390cb8cea381abf0a (diff)
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
-rw-r--r--Documentation/prolog-cookbook.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/Documentation/prolog-cookbook.txt b/Documentation/prolog-cookbook.txt
index c4a0589f0e..e660067a87 100644
--- a/Documentation/prolog-cookbook.txt
+++ b/Documentation/prolog-cookbook.txt
@@ -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]