upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-02-19 06:55:19 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-02-19 06:55:19 +0000
commit59e3b9cec5fa8cec400301ebaa18d5900166afbf (patch)
tree29da4eef77e41d63fe63868450cef0e765e3de7b
parent3bf83e6437a29de9b6fc57a3641d923e1b2a8cb5 (diff)
fix: ingore patch diff in descrition fallback
the description is not currently displayed so no tests where written
-rw-r--r--src/sub_commands/send.rs11
1 files 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<CoverLetter> {
486 .unwrap_or(event.content.len() - 1 - title_index) 486 .unwrap_or(event.content.len() - 1 - title_index)
487 + title_index; 487 + title_index;
488 488
489 let description_index_end = event.content[title_index..]
490 .find("\ndiff --git")
491 .unwrap_or(event.content.len() - 1)
492 + title_index;
493
489 let title = if let Ok(msg) = tag_value(event, "description") { 494 let title = if let Ok(msg) = tag_value(event, "description") {
490 msg.split('\n').collect::<Vec<&str>>()[0].to_string() 495 msg.split('\n').collect::<Vec<&str>>()[0].to_string()
491 } else { 496 } else {
492 event.content[title_index..description_index].to_string() 497 event.content[title_index..description_index].to_string()
493 }; 498 };
494 499
495 // note: if the description field is removed from patch events like in gitstr,
496 // then this will show entire patch. I'm not sure it is ever displayed though
497 let description = if let Ok(msg) = tag_value(event, "description") { 500 let description = if let Ok(msg) = tag_value(event, "description") {
498 if let Some((_before, after)) = msg.split_once('\n') { 501 if let Some((_before, after)) = msg.split_once('\n') {
499 after.trim().to_string() 502 after.trim().to_string()
@@ -501,7 +504,9 @@ pub fn event_to_cover_letter(event: &nostr::Event) -> Result<CoverLetter> {
501 String::new() 504 String::new()
502 } 505 }
503 } else { 506 } else {
504 event.content[description_index..].trim().to_string() 507 event.content[description_index..=description_index_end]
508 .trim()
509 .to_string()
505 }; 510 };
506 511
507 Ok(CoverLetter { 512 Ok(CoverLetter {