Skip to content

Commit

Permalink
make is_pipeline_allowed fn clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
thatportugueseguy committed Dec 17, 2024
1 parent 119dee9 commit 920b514
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/action.ml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
Lwt.return (direct_message @ chans)
in
let%lwt recipients =
if Context.is_pipeline_allowed ctx repo.url ~context then begin
if Context.is_pipeline_allowed ctx repo.url n then begin
match Rule.Status.match_rules ~rules n with
| Some (Ignore, _, _) | None -> Lwt.return []
| Some (Allow, notify_channels, notify_dm) -> action_on_match n.branches ~notify_channels ~notify_dm
Expand Down
10 changes: 5 additions & 5 deletions lib/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ let hook_of_channel ctx channel_name =
| Some hook -> Some hook.url
| None -> None

(** [is_pipeline_allowed ctx repo_url ~pipeline] returns [true] if [status_rules]
(** [is_pipeline_allowed ctx repo_url notification] returns [true] if [status_rules]
doesn't define a whitelist of allowed pipelines in the config of [repo_url],
or if the list contains [pipeline]; returns [false] otherwise. *)
let is_pipeline_allowed ctx repo_url ~context =
let is_pipeline_allowed ctx repo_url (n : Github_t.status_notification) =
match find_repo_config ctx repo_url with
| None -> true
| Some config ->
match config.status_rules.allowed_pipelines with
| Some allowed_pipelines
when not @@ List.exists (fun (p : Config_t.pipeline) -> String.equal p.name context) allowed_pipelines ->
false
| _ -> true
when List.exists (fun (p : Config_t.pipeline) -> String.equal p.name n.context) allowed_pipelines ->
true
| _ -> false

let refresh_secrets ctx =
let open Util in
Expand Down

0 comments on commit 920b514

Please sign in to comment.