Prolog cookbook: fix several examples.

* The Example 13: 1+1=2 Code-Review was broken, the fix was missing in I131e2008ba
  previous fix. Fix the following error:
    test output invalid result: submit(label(Code-Review,ok(_535EC2E6))). Reason: A label with the status Code-Review: OK must contain a user.

* Example 6: Make change submittable if commit author is "John Doe" was
  probably missing the user(ID)

Change-Id: I4126f01d979b4511faa83d4f779f83599c51c29a
This commit is contained in:
Kévin Raymond 2017-10-22 19:18:07 +02:00 committed by David Pursehouse
parent d2b8ed4b87
commit 6ca0726997

View File

@ -544,6 +544,7 @@ submit_rule(submit(Author)) :-
Author = label('Author-is-John-Doe', need(_)).
submit_rule(submit(Author)) :-
A = user(1000000),
gerrit:commit_author(A, 'John Doe', 'john.doe@example.com'),
Author = label('Author-is-John-Doe', ok(A)).
----
@ -899,7 +900,10 @@ add_category_min_score(In, Category, Min, P) :-
findall(X, gerrit:commit_label(label(Category,X),R),Z),
sum_list(Z, Sum),
Sum >= Min, !,
P = [label(Category,ok(R)) | In].
gerrit:commit_label(label(Category, V), U),
V >= 1,
!,
P = [label(Category,ok(U)) | In].
add_category_min_score(In, Category,Min,P) :-
P = [label(Category,need(Min)) | In].