From 069a4c21c56291455fb9af09b693672889f98a03 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 13 Sep 2024 17:00:00 +0100 Subject: refactor: abstract find pr from branch name so it is done consistantly across ngit and the remote helper --- src/bin/git_remote_nostr/utils.rs | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'src/bin/git_remote_nostr/utils.rs') diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index 15a0d76..bbe7cfa 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs @@ -16,8 +16,8 @@ use ngit::{ Repo, RepoActions, }, git_events::{ - event_is_revision_root, event_to_cover_letter, get_most_recent_patch_with_ancestors, - status_kinds, + event_is_revision_root, get_most_recent_patch_with_ancestors, + is_event_proposal_root_for_branch, status_kinds, }, repo_ref::RepoRef, }; @@ -189,24 +189,7 @@ pub fn find_proposal_and_patches_by_branch_name<'a>( current_user: &Option, ) -> Option<(&'a EventId, &'a (Event, Vec))> { open_proposals.iter().find(|(_, (proposal, _))| { - if let Ok(cl) = event_to_cover_letter(proposal) { - if let Ok(mut branch_name) = cl.get_branch_name() { - branch_name = if let Some(public_key) = current_user { - if proposal.author().eq(public_key) { - cl.branch_name.to_string() - } else { - branch_name - } - } else { - branch_name - }; - branch_name.eq(&refstr.replace("refs/heads/", "")) - } else { - false - } - } else { - false - } + is_event_proposal_root_for_branch(proposal, refstr, current_user).unwrap_or(false) }) } -- cgit v1.2.3