diff options
Diffstat (limited to 'src/sub_commands/prs/create.rs')
| -rw-r--r-- | src/sub_commands/prs/create.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/sub_commands/prs/create.rs b/src/sub_commands/prs/create.rs index e5a7c1e..35e29d3 100644 --- a/src/sub_commands/prs/create.rs +++ b/src/sub_commands/prs/create.rs | |||
| @@ -349,7 +349,6 @@ mod tests_unique_and_duplicate { | |||
| 349 | } | 349 | } |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | pub static PR_KIND: u64 = 318; | ||
| 353 | pub static PATCH_KIND: u64 = 1617; | 352 | pub static PATCH_KIND: u64 = 1617; |
| 354 | 353 | ||
| 355 | pub fn generate_pr_and_patch_events( | 354 | pub fn generate_pr_and_patch_events( |
| @@ -367,7 +366,7 @@ pub fn generate_pr_and_patch_events( | |||
| 367 | 366 | ||
| 368 | if let Some((title, description)) = cover_letter_title_description { | 367 | if let Some((title, description)) = cover_letter_title_description { |
| 369 | events.push(EventBuilder::new( | 368 | events.push(EventBuilder::new( |
| 370 | nostr::event::Kind::Custom(PR_KIND), | 369 | nostr::event::Kind::Custom(PATCH_KIND), |
| 371 | format!( | 370 | format!( |
| 372 | "From {} Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/{}] {title}\n\n{description}", | 371 | "From {} Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/{}] {title}\n\n{description}", |
| 373 | commits.last().unwrap(), | 372 | commits.last().unwrap(), |
| @@ -444,7 +443,12 @@ pub struct CoverLetter { | |||
| 444 | } | 443 | } |
| 445 | 444 | ||
| 446 | pub fn event_is_cover_letter(event: &nostr::Event) -> bool { | 445 | pub fn event_is_cover_letter(event: &nostr::Event) -> bool { |
| 447 | event.kind.as_u64().eq(&PR_KIND) && event.iter_tags().any(|t| t.as_vec()[1].eq("cover-letter")) | 446 | // TODO: look for Subject:[ PATCH 0/n ] but watch out for: |
| 447 | // [PATCH v1 0/n ] or | ||
| 448 | // [PATCH subsystem v2 0/n ] | ||
| 449 | event.kind.as_u64().eq(&PATCH_KIND) | ||
| 450 | && event.iter_tags().any(|t| t.as_vec()[1].eq("root")) | ||
| 451 | && event.iter_tags().any(|t| t.as_vec()[1].eq("cover-letter")) | ||
| 448 | } | 452 | } |
| 449 | pub fn event_to_cover_letter(event: &nostr::Event) -> Result<CoverLetter> { | 453 | pub fn event_to_cover_letter(event: &nostr::Event) -> Result<CoverLetter> { |
| 450 | if !event_is_patch_set_root(event) { | 454 | if !event_is_patch_set_root(event) { |
| @@ -502,8 +506,7 @@ pub fn event_to_cover_letter(event: &nostr::Event) -> Result<CoverLetter> { | |||
| 502 | } | 506 | } |
| 503 | 507 | ||
| 504 | pub fn event_is_patch_set_root(event: &nostr::Event) -> bool { | 508 | pub fn event_is_patch_set_root(event: &nostr::Event) -> bool { |
| 505 | (event.kind.as_u64().eq(&PR_KIND) || event.kind.as_u64().eq(&PATCH_KIND)) | 509 | event.kind.as_u64().eq(&PATCH_KIND) && event.iter_tags().any(|t| t.as_vec()[1].eq("root")) |
| 506 | && event.iter_tags().any(|t| t.as_vec()[1].eq("root")) | ||
| 507 | } | 510 | } |
| 508 | 511 | ||
| 509 | #[allow(clippy::too_many_arguments)] | 512 | #[allow(clippy::too_many_arguments)] |
| @@ -848,7 +851,7 @@ mod tests { | |||
| 848 | 851 | ||
| 849 | fn generate_cover_letter(title: &str, description: &str) -> Result<nostr::Event> { | 852 | fn generate_cover_letter(title: &str, description: &str) -> Result<nostr::Event> { |
| 850 | Ok(nostr::event::EventBuilder::new( | 853 | Ok(nostr::event::EventBuilder::new( |
| 851 | nostr::event::Kind::Custom(PR_KIND), | 854 | nostr::event::Kind::Custom(PATCH_KIND), |
| 852 | format!("From ea897e987ea9a7a98e7a987e97987ea98e7a3334 Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/2] {title}\n\n{description}"), | 855 | format!("From ea897e987ea9a7a98e7a987e97987ea98e7a3334 Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/2] {title}\n\n{description}"), |
| 853 | [ | 856 | [ |
| 854 | Tag::Hashtag("cover-letter".to_string()), | 857 | Tag::Hashtag("cover-letter".to_string()), |