Add per-project prolog submit rule files
When loading the prolog environment, now checks refs/meta/config branch for a file called rules.pl. If it exists, consult the file. Expects a predicate called submit_rule. If no file is found, uses the default_submit predicate in common_rules.pl. Change-Id: Ia76d0dc5aba67cf3c68c56589fe013c63157bca5
This commit is contained in:

committed by
Shawn O. Pearce

parent
9f2535231b
commit
f93796cd53
@@ -143,7 +143,7 @@ not_same(_, _).
|
||||
%%
|
||||
%% can_submit/2:
|
||||
%%
|
||||
%% Execute the SubmitRule for each solution until one where all of the
|
||||
%% Executes the SubmitRule for each solution until one where all of the
|
||||
%% states has the format label(_, ok(_)) is found, then cut away any
|
||||
%% remaining choice points leaving this as the last solution.
|
||||
%%
|
||||
@@ -162,6 +162,30 @@ is_all_ok([label(_, ok(__)) | Ls]) :- is_all_ok(Ls).
|
||||
is_all_ok(_) :- fail.
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
%% locate_submit_rule/1:
|
||||
%%
|
||||
%% Finds a submit_rule depending on what rules are available.
|
||||
%% If none are available, use default_submit/1.
|
||||
%%
|
||||
:- public locate_submit_rule/1.
|
||||
%%
|
||||
|
||||
locate_submit_rule(RuleName) :-
|
||||
clause(user:submit_rule(_), _),
|
||||
!,
|
||||
RuleName = user:submit_rule
|
||||
.
|
||||
locate_submit_rule(RuleName) :-
|
||||
'$compiled_predicate'(user, submit_rule, 1),
|
||||
!,
|
||||
RuleName = user:submit_rule
|
||||
.
|
||||
locate_submit_rule(RuleName) :-
|
||||
RuleName = 'com.google.gerrit.rules.common':default_submit.
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
%% default_submit/1:
|
||||
|
Reference in New Issue
Block a user