From 91783b906697fc85305dee683f7c15dda55f0c50 Mon Sep 17 00:00:00 2001 From: Angelo Kontaxis Date: Sat, 28 Mar 2026 00:29:37 +0000 Subject: [PATCH] fix: only show first line on commit messages (#696) Signed-off-by: Zomatree --- .../routes/webhooks/webhook_execute_github.rs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/delta/src/routes/webhooks/webhook_execute_github.rs b/crates/delta/src/routes/webhooks/webhook_execute_github.rs index 124b2e97..049392d2 100644 --- a/crates/delta/src/routes/webhooks/webhook_execute_github.rs +++ b/crates/delta/src/routes/webhooks/webhook_execute_github.rs @@ -688,11 +688,23 @@ const LIGHT_ORANGE: &str = "#d9916d"; // for future use // const WHITE: &str = "#c3e1c3"; -fn shorten_text(text: &str, length: usize) -> String { - if text.len() < length { - text.to_string() +fn shorten_single_line_text(text: &str, length: usize) -> String { + if text.contains('\n') { + let text = text.split('\n').next().unwrap(); + + format!("{}...", &text[..text.len().min(length) - 3]) + } else if text.len() > length { + format!("{}...", &text[..length - 3]) } else { - format!("{}...", &text[0..length]) + text.to_string() + } +} + +fn shorten_text(text: &str, length: usize) -> String { + if text.len() >= length { + format!("{}...", &text[..length - 3]) + } else { + text.to_string() } } @@ -823,7 +835,7 @@ pub async fn webhook_execute_github( "[`{}`]({}) {} - {}", &commit.id[0..=7], commit.url, - shorten_text(&commit.message, 50), + shorten_single_line_text(&commit.message, 50), commit.author.name ) })