Tested on 2.7-rc0. Originally encountered on 2.5.2.
My understanding from the documentation and examples and comments in the code, is that Gerrit effectively tries to find all solutions to submit_rule(X), and if any one of those solutions is all ok then it returns a single OK result and accepts the change; otherwise it returns one or more NOT_READY results and refuses the change.
With some rules based on http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/prolog-cookbook.html#_example_5_the_em_need_8230_em_labels_not_shown_when_change_is_submittable (which seems to be saying that the order of submit_rules is insignificant), I get:
$ cat rules.pl
submit_rule(submit(label('Some-Condition', need(_)))).
submit_rule(submit(label('Another-Condition', ok(_)))).
submit_rule(submit(label('Yet-Another-Condition', need(_)))).
$ cat rules.pl | ssh -p 29418 ... gerrit test-submit rule -s ...
[
{
"status": "OK",
"ok": {
"Another-Condition": {}
}
},
{
"status": "NOT_READY",
"need": {
"Yet-Another-Condition": {}
}
}
]
It hasn't stopped after finding the OK solution, and it found one of the NOT_READY solutions too. I think this means it will refuse to submit the patch. (I haven't tested submission on 2.7-rc0, but did see a submission refusal when using a similar set of rules on 2.5.2.)
Expected output is just the single OK result.
(If I'm wrong and the code is correct to return both OK and NOT_READY in this case, then I think the documentation is very misleading!)