Skip to content

Commit 2edb227

Browse files
committed
non-main branch build notifications go to default channel only (ref #81)
1 parent 3d14daa commit 2edb227

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lib/action.ml

+21-9
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,28 @@ let hide_success (n : status_notification) (ctx : Context.t) =
216216
let partition_status (ctx : Context.t) (n : status_notification) =
217217
let cfg = ctx.cfg in
218218
let get_commit_info () =
219-
match%lwt Github.generate_query_commmit cfg ~url:n.commit.url ~sha:n.commit.sha with
220-
| None -> Lwt.return @@ Option.to_list cfg.prefix_rules.default
221-
| Some commit ->
222-
match
223-
List.exists n.branches ~f:(fun { name } -> is_main_merge_message ~msg:commit.commit.message ~branch:name cfg)
224-
with
219+
let default () = Lwt.return @@ Option.to_list cfg.prefix_rules.default in
220+
match cfg.main_branch_name with
221+
| None -> default ()
222+
| Some main_branch_name ->
223+
(* non-main branch build notifications go to default channel to reduce spam in topic channels *)
224+
match List.exists n.branches ~f:(fun { name } -> String.equal name main_branch_name) with
225+
| false -> default ()
225226
| true ->
226-
log#info "main branch merge, ignoring status event %s: %s" n.context (first_line commit.commit.message);
227-
Lwt.return []
228-
| false -> Lwt.return (partition_commit cfg commit.files)
227+
( match%lwt Github.generate_query_commmit cfg ~url:n.commit.url ~sha:n.commit.sha with
228+
| None -> default ()
229+
| Some commit ->
230+
(*
231+
match
232+
List.exists n.branches ~f:(fun { name } -> is_main_merge_message ~msg:commit.commit.message ~branch:name cfg)
233+
with
234+
| true ->
235+
log#info "main branch merge, ignoring status event %s: %s" n.context (first_line commit.commit.message);
236+
Lwt.return []
237+
| false ->
238+
*)
239+
Lwt.return (partition_commit cfg commit.files)
240+
)
229241
in
230242
let res =
231243
match

0 commit comments

Comments
 (0)