Skip to content

Commit 3d14daa

Browse files
committed
minor
1 parent 1d12c2a commit 3d14daa

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/action.ml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ let partition_push cfg n =
110110
|> List.concat
111111
in
112112
let prefix_chans =
113-
let chans = List.map rules ~f:(fun (rule : prefix_rule) -> rule.chan) in
114-
let chans = Option.value_map cfg.prefix_rules.default ~default:chans ~f:(fun default -> default :: chans) in
113+
let chans = Option.to_list cfg.prefix_rules.default @ List.map rules ~f:(fun (rule : prefix_rule) -> rule.chan) in
115114
List.dedup_and_sort chans ~compare:String.compare
116115
in
117116
List.filter_map prefix_chans ~f:(fun chan ->
@@ -127,7 +126,7 @@ let filter_label rules label =
127126
| true -> Some rule.chan)
128127

129128
let partition_label cfg labels =
130-
let default = Option.value_map cfg.label_rules.default ~default:[] ~f:(fun webhook -> [ webhook ]) in
129+
let default = Option.to_list cfg.label_rules.default in
131130
match labels with
132131
| [] -> default
133132
| labels ->
@@ -181,10 +180,7 @@ let partition_commit cfg files =
181180
let names = List.map ~f:(fun f -> f.filename) files in
182181
match unique_chans_of_files cfg.prefix_rules.rules names with
183182
| _ :: _ as xs -> xs
184-
| [] ->
185-
match cfg.prefix_rules.default with
186-
| Some webhook -> [ webhook ]
187-
| None -> []
183+
| [] -> Option.to_list cfg.prefix_rules.default
188184

189185
let hide_cancelled (notification : status_notification) cfg =
190186
let find_cancelled status_state =
@@ -221,9 +217,7 @@ let partition_status (ctx : Context.t) (n : status_notification) =
221217
let cfg = ctx.cfg in
222218
let get_commit_info () =
223219
match%lwt Github.generate_query_commmit cfg ~url:n.commit.url ~sha:n.commit.sha with
224-
| None ->
225-
let default = Option.value_map cfg.prefix_rules.default ~default:[] ~f:(fun webhook -> [ webhook ]) in
226-
Lwt.return default
220+
| None -> Lwt.return @@ Option.to_list cfg.prefix_rules.default
227221
| Some commit ->
228222
match
229223
List.exists n.branches ~f:(fun { name } -> is_main_merge_message ~msg:commit.commit.message ~branch:name cfg)
@@ -257,7 +251,7 @@ let partition_status (ctx : Context.t) (n : status_notification) =
257251
res
258252

259253
let partition_commit_comment cfg n =
260-
let default = Option.value_map cfg.prefix_rules.default ~default:[] ~f:(fun webhook -> [ webhook ]) in
254+
let default = Option.to_list cfg.prefix_rules.default in
261255
match n.comment.path with
262256
| None ->
263257
( match%lwt Github.generate_commit_from_commit_comment cfg n with

0 commit comments

Comments
 (0)