Skip to content

Commit 8422299

Browse files
committed
make fields short and space-pad list fields
1 parent 84745e4 commit 8422299

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lib/slack.atd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ type 'v map_as_object <ocaml from="State"> = abstract
33
type message_field = {
44
?title: string nullable;
55
value: string;
6+
~short <ocaml default="false">: bool;
67
}
78

89
type message_attachment = {

lib/slack.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ let generate_push_notification notification channel =
259259
mrkdwn_in = Some [ "fields" ];
260260
fallback = Some "Commit pushed notification";
261261
color = Some "#ccc";
262-
fields = Some [ { value = String.concat ~sep:"\n" commits; title = None } ];
262+
fields = Some [ { value = String.concat ~sep:"\n" commits; title = None; short = false } ];
263263
};
264264
];
265265
blocks = None;
@@ -315,6 +315,7 @@ let generate_status_notification (cfg : Config_t.config) (notification : status_
315315
(sprintf "<%s|[%s]> CI Build Status notification for <%s|%s>: %s" repository.url repository.full_name t context
316316
state_info)
317317
in
318+
let msg = String.concat ~sep:"\n" @@ List.concat [ commit_info; branches_info ] in
318319
let attachment =
319320
{
320321
empty_attachments with
@@ -323,7 +324,7 @@ let generate_status_notification (cfg : Config_t.config) (notification : status_
323324
pretext = summary;
324325
color = Some color_info;
325326
text = description_info;
326-
fields = Some [ { title = None; value = String.concat ~sep:"\n" @@ List.concat [ commit_info; branches_info ] } ];
327+
fields = Some [ { title = None; value = msg; short = false } ];
327328
}
328329
in
329330
{ channel; text = None; attachments = Some [ attachment ]; blocks = None }

lib/slack_message.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ let populate_pull_request repository (pull_request : pull_request) =
7777
"Comments", [ Int.to_string comments ];
7878
"Reviewers", get_reviewers ();
7979
]
80-
|> List.filter_map ~f:(fun (t, v) -> if List.is_empty v then None else Some (t, String.concat v ~sep:","))
81-
|> List.map ~f:(fun (t, v) -> { title = Some t; value = v })
80+
|> List.filter_map ~f:(fun (t, v) -> if List.is_empty v then None else Some (t, String.concat v ~sep:", "))
81+
|> List.map ~f:(fun (t, v) -> { title = Some t; value = v; short = true })
8282
in
8383
let get_title () = sprintf "#%d %s" number (Mrkdwn.escape_mrkdwn title) in
8484
{
@@ -103,8 +103,8 @@ let populate_issue repository (issue : issue) =
103103
"Labels", List.map labels ~f:pp_label;
104104
"Comments", [ Int.to_string comments ];
105105
]
106-
|> List.filter_map ~f:(fun (t, v) -> if List.is_empty v then None else Some (t, String.concat v ~sep:","))
107-
|> List.map ~f:(fun (t, v) -> { title = Some t; value = v })
106+
|> List.filter_map ~f:(fun (t, v) -> if List.is_empty v then None else Some (t, String.concat v ~sep:", "))
107+
|> List.map ~f:(fun (t, v) -> { title = Some t; value = v; short = true })
108108
in
109109
let get_title () = sprintf "#%d %s" number (Mrkdwn.escape_mrkdwn title) in
110110
{

0 commit comments

Comments
 (0)