Skip to content

Commit 722c5c4

Browse files
committed
slack: shorten commits list in middle
so that merge commits at the end of the list remain visible
1 parent e977be5 commit 722c5c4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/slack.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ let generate_push_notification notification channel =
268268
(* truncation point depends on line length, but 10 lines seems okay for most cases *)
269269
let num_shown = 10 in
270270
let dropped = num_commits - num_shown in
271-
if dropped > 0 then
272-
List.rev_map_append (List.drop (List.rev commits) dropped) [ sprintf "+%d more..." dropped ] ~f:pp_commit
271+
if dropped > 0 then begin
272+
let h, commits' = List.split_n commits (num_shown / 2) in
273+
let t = List.drop commits' dropped in
274+
List.concat [ List.map ~f:pp_commit h; [ sprintf "+%d more..." dropped ]; List.map ~f:pp_commit t ]
275+
end
273276
else List.map commits ~f:pp_commit
274277
in
275278
{

0 commit comments

Comments
 (0)