Support controlling the submit type for changes from Prolog
Similarly like the "submit_rule" there is now a "submit_type" predicate which returns the allowed submit type for a change. When the submit_type predicate is not provided in the rules.pl then the project default submit type is used for all changes for that project. Filtering the results of the submit_type is also supported in the same way like filtering the results of the submit_rule. Using a submit_type_filter predicate one can enforce a particular submit type from a parent project. For example, a release engineer may want to enforce the FAST_FORWARD_ONLY submit type for all changes pushed to stable release branches while, at the same time, use the project wide default submit type for changes pushed to the development branch. Change-Id: Iec08f412723856b40324a6e0ec00ac523be9a3b6 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
This commit is contained in:

committed by
Gerrit Code Review

parent
162c801f4b
commit
680a5f80d9
@@ -140,12 +140,12 @@ not_same(_, _).
|
||||
:- public can_submit/2.
|
||||
%%
|
||||
can_submit(SubmitRule, S) :-
|
||||
call_submit_rule(SubmitRule, Tmp),
|
||||
call_rule(SubmitRule, Tmp),
|
||||
Tmp =.. [submit | Ls],
|
||||
( is_all_ok(Ls) -> S = ok(Tmp), ! ; S = not_ready(Tmp) ).
|
||||
|
||||
call_submit_rule(P:X, Arg) :- !, F =.. [X, Arg], P:F.
|
||||
call_submit_rule(X, Arg) :- !, F =.. [X, Arg], F.
|
||||
call_rule(P:X, Arg) :- !, F =.. [X, Arg], P:F.
|
||||
call_rule(X, Arg) :- !, F =.. [X, Arg], F.
|
||||
|
||||
is_all_ok([]).
|
||||
is_all_ok([label(_, ok(__)) | Ls]) :- is_all_ok(Ls).
|
||||
@@ -182,6 +182,31 @@ locate_submit_rule(RuleName) :-
|
||||
locate_helper(submit_rule, default_submit, 1, RuleName).
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
%% get_submit_type/2:
|
||||
%%
|
||||
%% Executes the SubmitTypeRule and return the first solution
|
||||
%%
|
||||
:- public get_submit_type/2.
|
||||
%%
|
||||
get_submit_type(SubmitTypeRule, A) :-
|
||||
call_rule(SubmitTypeRule, A), !.
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
%% locate_submit_type/1:
|
||||
%%
|
||||
%% Finds a submit_type_rule depending on what rules are available.
|
||||
%% If none are available, use project_default_submit_type/1.
|
||||
%%
|
||||
:- public locate_submit_type/1.
|
||||
%%
|
||||
locate_submit_type(RuleName) :-
|
||||
locate_helper(submit_type, project_default_submit_type, 1, RuleName).
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
%% default_submit/1:
|
||||
@@ -311,6 +336,17 @@ filter_submit_results(Filter, [], Out, Out).
|
||||
call_submit_filter(P:X, R, S) :- !, F =.. [X, R, S], P:F.
|
||||
call_submit_filter(X, R, S) :- F =.. [X, R, S], F.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
%% filter_submit_type_results/3:
|
||||
%%
|
||||
%% Executes the submit_type_filter against the result,
|
||||
%% returns the filtered result.
|
||||
%%
|
||||
:- public filter_submit_type_results/3.
|
||||
%%
|
||||
filter_submit_type_results(Filter, In, Out) :- call_submit_filter(Filter, In, Out).
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
@@ -331,6 +367,16 @@ locate_submit_filter(FilterName) :-
|
||||
%%
|
||||
noop_filter(In, In).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
%% locate_submit_type_filter/1:
|
||||
%%
|
||||
%% Finds a submit_type_filter if available.
|
||||
%%
|
||||
:- public locate_submit_type_filter/1.
|
||||
%%
|
||||
locate_submit_type_filter(FilterName) :-
|
||||
locate_helper(submit_type_filter, noop_filter, 2, FilterName).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
|
Reference in New Issue
Block a user