From 1d8009cad12df7b95e39de8fb124233a112adf4e Mon Sep 17 00:00:00 2001 From: Patrick Marie Date: Thu, 6 Feb 2025 23:43:25 +0100 Subject: [PATCH] feat(log): show first log line --- src/log.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/log.rs b/src/log.rs index 707570f..73ea475 100644 --- a/src/log.rs +++ b/src/log.rs @@ -13,7 +13,14 @@ impl Repository { let commit_desc = commit.string()?; let lines = commit_desc.lines().collect::>(); - println!("{} {}", hex::encode(current_commit), lines[lines.len() - 1]); + // find the first empty line + let first_empty_line = lines.iter().position(|line| line.is_empty()); + + println!( + "{} {}", + hex::encode(current_commit), + lines[first_empty_line.unwrap() + 1] + ); let parent_commit_id = lines.iter().find(|line| line.starts_with("parent ")); if parent_commit_id.is_none() {