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 { } } -pub static PR_KIND: u64 = 318; pub static PATCH_KIND: u64 = 1617; pub fn generate_pr_and_patch_events( @@ -367,7 +366,7 @@ pub fn generate_pr_and_patch_events( if let Some((title, description)) = cover_letter_title_description { events.push(EventBuilder::new( - nostr::event::Kind::Custom(PR_KIND), + nostr::event::Kind::Custom(PATCH_KIND), format!( "From {} Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/{}] {title}\n\n{description}", commits.last().unwrap(), @@ -444,7 +443,12 @@ pub struct CoverLetter { } pub fn event_is_cover_letter(event: &nostr::Event) -> bool { - event.kind.as_u64().eq(&PR_KIND) && event.iter_tags().any(|t| t.as_vec()[1].eq("cover-letter")) + // TODO: look for Subject:[ PATCH 0/n ] but watch out for: + // [PATCH v1 0/n ] or + // [PATCH subsystem v2 0/n ] + event.kind.as_u64().eq(&PATCH_KIND) + && event.iter_tags().any(|t| t.as_vec()[1].eq("root")) + && event.iter_tags().any(|t| t.as_vec()[1].eq("cover-letter")) } pub fn event_to_cover_letter(event: &nostr::Event) -> Result { if !event_is_patch_set_root(event) { @@ -502,8 +506,7 @@ pub fn event_to_cover_letter(event: &nostr::Event) -> Result { } pub fn event_is_patch_set_root(event: &nostr::Event) -> bool { - (event.kind.as_u64().eq(&PR_KIND) || event.kind.as_u64().eq(&PATCH_KIND)) - && event.iter_tags().any(|t| t.as_vec()[1].eq("root")) + event.kind.as_u64().eq(&PATCH_KIND) && event.iter_tags().any(|t| t.as_vec()[1].eq("root")) } #[allow(clippy::too_many_arguments)] @@ -848,7 +851,7 @@ mod tests { fn generate_cover_letter(title: &str, description: &str) -> Result { Ok(nostr::event::EventBuilder::new( - nostr::event::Kind::Custom(PR_KIND), + nostr::event::Kind::Custom(PATCH_KIND), format!("From ea897e987ea9a7a98e7a987e97987ea98e7a3334 Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/2] {title}\n\n{description}"), [ Tag::Hashtag("cover-letter".to_string()), diff --git a/src/sub_commands/prs/list.rs b/src/sub_commands/prs/list.rs index 36cbd02..d4dcfec 100644 --- a/src/sub_commands/prs/list.rs +++ b/src/sub_commands/prs/list.rs @@ -10,9 +10,7 @@ use crate::{ client::Connect, git::{Repo, RepoActions}, repo_ref::{self, RepoRef, REPO_REF_KIND}, - sub_commands::prs::create::{ - event_is_cover_letter, event_to_cover_letter, PATCH_KIND, PR_KIND, - }, + sub_commands::prs::create::{event_is_cover_letter, event_to_cover_letter, PATCH_KIND}, Cli, }; @@ -195,10 +193,7 @@ pub async fn find_pr_events( repo_ref.relays.clone(), vec![ nostr::Filter::default() - .kinds(vec![ - nostr::Kind::Custom(PR_KIND), - nostr::Kind::Custom(PATCH_KIND), - ]) + .kind(nostr::Kind::Custom(PATCH_KIND)) .custom_tag(nostr::Alphabet::T, vec!["root"]) .identifiers( repo_ref @@ -208,10 +203,7 @@ pub async fn find_pr_events( ), // also pick up prs from the same repo but no target at our maintainers repo events nostr::Filter::default() - .kinds(vec![ - nostr::Kind::Custom(PR_KIND), - nostr::Kind::Custom(PATCH_KIND), - ]) + .kind(nostr::Kind::Custom(PATCH_KIND)) .custom_tag(nostr::Alphabet::T, vec!["root"]) .reference(root_commit), ], diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 0e34983..089b052 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -11,7 +11,6 @@ use strip_ansi_escapes::strip_str; pub mod git; pub mod relay; -pub static PR_KIND: u64 = 318; pub static PATCH_KIND: u64 = 1617; pub static REPOSITORY_KIND: u64 = 30617; diff --git a/tests/prs_create.rs b/tests/prs_create.rs index 316c9fe..5d55ab9 100644 --- a/tests/prs_create.rs +++ b/tests/prs_create.rs @@ -143,7 +143,8 @@ fn cli_message_creating_patches() -> Result<()> { } fn is_cover_letter(event: &nostr::Event) -> bool { - event.kind.as_u64().eq(&PR_KIND) && event.iter_tags().any(|t| t.as_vec()[1].eq("cover-letter")) + event.kind.as_u64().eq(&PATCH_KIND) + && event.iter_tags().any(|t| t.as_vec()[1].eq("cover-letter")) } fn is_patch(event: &nostr::Event) -> bool {