From 4bf48c80415a083ab89057996ebb7d785ca105f7 Mon Sep 17 00:00:00 2001 From: ip Date: Fri, 23 Oct 2020 18:13:04 -0400 Subject: [PATCH] non-main branch build notifications go to default channel only (ref #81) --- lib/action.ml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/action.ml b/lib/action.ml index ceaff8e2..daf2baff 100644 --- a/lib/action.ml +++ b/lib/action.ml @@ -216,16 +216,28 @@ let hide_success (n : status_notification) (ctx : Context.t) = let partition_status (ctx : Context.t) (n : status_notification) = let cfg = ctx.cfg in let get_commit_info () = - match%lwt Github.generate_query_commmit cfg ~url:n.commit.url ~sha:n.commit.sha with - | None -> Lwt.return @@ Option.to_list cfg.prefix_rules.default - | Some commit -> - match - List.exists n.branches ~f:(fun { name } -> is_main_merge_message ~msg:commit.commit.message ~branch:name cfg) - with + let default () = Lwt.return @@ Option.to_list cfg.prefix_rules.default in + match cfg.main_branch_name with + | None -> default () + | Some main_branch_name -> + (* non-main branch build notifications go to default channel to reduce spam in topic channels *) + match List.exists n.branches ~f:(fun { name } -> String.equal name main_branch_name) with + | false -> default () | true -> - log#info "main branch merge, ignoring status event %s: %s" n.context (first_line commit.commit.message); - Lwt.return [] - | false -> Lwt.return (partition_commit cfg commit.files) + ( match%lwt Github.generate_query_commmit cfg ~url:n.commit.url ~sha:n.commit.sha with + | None -> default () + | Some commit -> + (* + match + List.exists n.branches ~f:(fun { name } -> is_main_merge_message ~msg:commit.commit.message ~branch:name cfg) + with + | true -> + log#info "main branch merge, ignoring status event %s: %s" n.context (first_line commit.commit.message); + Lwt.return [] + | false -> +*) + Lwt.return (partition_commit cfg commit.files) + ) in let res = match