I am new to Gerrit and Prolog, and am having difficulty creating my rule. With the rules.pl I currently have, it stalls when I try to open the Gerrit window after running the push command.
What I'd like is to make a rule that at each push to the remote, a .txt file needs to be present in the list of changed files. I saw a similar rule in the Prolog cookbook, but mine is not correct yet. Here's what I have currently (have made some changes in the last 24hours):
submit_rule(S) :-
gerrit:default_submit(X),
X = .. [submit | Ls],
my_rule(Ls,R),
S = .. [submit | R].
my_rule(S1,T) :-
gerrit:commit_delta('\\.txt$),
T = label('Text-File-Must-Be-Present',ok(T)).
my_rule(S1,[label('Text-File-Must-Be-Present',need(_)) | S1]).
I think I am still missing something in my_rule. I need to be sure that commit_delta returned true. If not, then it should return false and block the push to the remote repo. Do I need something more like this?
gerrit:commit_delta('\\.txt$),
T \= false, !,
T = label('Text-File-Must-Be-Present',ok(T)).
in order to return if false is returned? Thanks again!
Don't know gerrit, but you have several syntax problems, maybe induced by some buggy text processing step:
gerrit:commit_delta('\\.txt$),
left the atom unterminated, hiding the subsequent bug (at least in Prologs not supporting SWI-Prolog extensions of compounds with 0 arity)
T = label('Text-File-Must-Be-Present',need()).
need()
should have at least 1 argument, or should be written down as need
.
If gerrit implements its own Prolog interpreter, it should be able to show somewhere an error report...
BTW, the first rule is more complex than needed. I would write
submit_rule(submit(R)) :-
gerrit:default_submit(R,submit(Ls)),
my_rule(R).
clearly showing you're forgetting to process Ls
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.