From 59e3b9cec5fa8cec400301ebaa18d5900166afbf Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 19 Feb 2024 06:55:19 +0000 Subject: fix: ingore patch diff in descrition fallback the description is not currently displayed so no tests where written --- src/sub_commands/send.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index ac1d182..403f1fd 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -486,14 +486,17 @@ pub fn event_to_cover_letter(event: &nostr::Event) -> Result { .unwrap_or(event.content.len() - 1 - title_index) + title_index; + let description_index_end = event.content[title_index..] + .find("\ndiff --git") + .unwrap_or(event.content.len() - 1) + + title_index; + let title = if let Ok(msg) = tag_value(event, "description") { msg.split('\n').collect::>()[0].to_string() } else { event.content[title_index..description_index].to_string() }; - // note: if the description field is removed from patch events like in gitstr, - // then this will show entire patch. I'm not sure it is ever displayed though let description = if let Ok(msg) = tag_value(event, "description") { if let Some((_before, after)) = msg.split_once('\n') { after.trim().to_string() @@ -501,7 +504,9 @@ pub fn event_to_cover_letter(event: &nostr::Event) -> Result { String::new() } } else { - event.content[description_index..].trim().to_string() + event.content[description_index..=description_index_end] + .trim() + .to_string() }; Ok(CoverLetter { -- cgit v1.2.3