From fedf5166f0c57db14b9e43747121e4b7845b63dd Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 20 Aug 2024 06:25:17 +0100 Subject: feat: set proposal branch prefix to `pr/` from `prs/`. whilst plural reflects usage of `heads` and `tags` in git refs, singular is shorter and more reflective of usage of branch prefixes such as `feature/` `fix/` --- src/git_remote_helper.rs | 10 +++++----- src/sub_commands/send.rs | 16 +++++++--------- test_utils/src/lib.rs | 2 +- tests/git_remote_helper.rs | 4 ++-- tests/list.rs | 8 ++++---- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs index 9b9b000..e55a2eb 100644 --- a/src/git_remote_helper.rs +++ b/src/git_remote_helper.rs @@ -233,7 +233,7 @@ async fn list( .clone() }; - state.retain(|k, _| !k.starts_with("refs/heads/prs/")); + state.retain(|k, _| !k.starts_with("refs/heads/pr/")); let open_proposals = get_open_proposals(git_repo, repo_ref).await?; let current_user = get_curent_user(git_repo)?; @@ -447,7 +447,7 @@ async fn fetch( let oids_from_git_servers = fetch_batch .iter() - .filter(|(refstr, _)| !refstr.contains("refs/heads/prs/")) + .filter(|(refstr, _)| !refstr.contains("refs/heads/pr/")) .map(|(_, oid)| oid.clone()) .collect::>(); @@ -488,7 +488,7 @@ async fn fetch( ); } - fetch_batch.retain(|refstr, _| refstr.contains("refs/heads/prs/")); + fetch_batch.retain(|refstr, _| refstr.contains("refs/heads/pr/")); if !fetch_batch.is_empty() { let open_proposals = get_open_proposals(git_repo, repo_ref).await?; @@ -580,13 +580,13 @@ async fn push( let proposal_refspecs = refspecs .iter() - .filter(|r| r.contains("refs/heads/prs/")) + .filter(|r| r.contains("refs/heads/pr/")) .cloned() .collect::>(); let mut git_server_refspecs = refspecs .iter() - .filter(|r| !r.contains("refs/heads/prs/")) + .filter(|r| !r.contains("refs/heads/pr/")) .cloned() .collect::>(); diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index a005bd7..8369b10 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -648,7 +648,7 @@ pub async fn generate_cover_letter_and_patch_events( vec![ Tag::custom( nostr::TagKind::Custom(std::borrow::Cow::Borrowed("branch-name")), - vec![if let Some(branch_name) = branch_name.strip_prefix("prs/") { + vec![if let Some(branch_name) = branch_name.strip_prefix("pr/") { branch_name.to_string() } else { branch_name @@ -691,13 +691,11 @@ pub async fn generate_cover_letter_and_patch_events( && !branch_name.eq("origin/main") && !branch_name.eq("origin/master") { - Some( - if let Some(branch_name) = branch_name.strip_prefix("prs/") { - branch_name.to_string() - } else { - branch_name - }, - ) + Some(if let Some(branch_name) = branch_name.strip_prefix("pr/") { + branch_name.to_string() + } else { + branch_name + }) } else { None } @@ -793,7 +791,7 @@ pub struct CoverLetter { impl CoverLetter { pub fn get_branch_name(&self) -> Result { Ok(format!( - "prs/{}({})", + "pr/{}({})", self.branch_name, &self .event_id diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 84ae8a9..56e9b17 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -1098,7 +1098,7 @@ pub fn get_proposal_branch_name_from_events( }) }) { return Ok(format!( - "prs/{}({})", + "pr/{}({})", branch_name_in_event, &event.id.to_hex().as_str()[..8], )); diff --git a/tests/git_remote_helper.rs b/tests/git_remote_helper.rs index cce8e42..a44b141 100644 --- a/tests/git_remote_helper.rs +++ b/tests/git_remote_helper.rs @@ -2173,7 +2173,7 @@ mod push { r55.events = events.clone(); let before = r55.events.iter().cloned().collect::>(); - let branch_name = "prs/my-new-proposal"; + let branch_name = "pr/my-new-proposal"; let cli_tester_handle = std::thread::spawn(move || -> Result { let mut git_repo = clone_git_repo_with_nostr_url()?; @@ -2250,7 +2250,7 @@ mod push { .find(|t| t.as_vec()[0].eq("branch-name")) .unwrap() .as_vec()[1], - branch_name.replace("prs/", ""), + branch_name.replace("pr/", ""), ); let second_patch = new_events diff --git a/tests/list.rs b/tests/list.rs index ce90ee4..c145fa4 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -197,7 +197,7 @@ mod when_main_branch_is_uptodate { )?; c.succeeds_with(0, false, None)?; p.expect(&format!( - "checked out proposal as 'prs/{}(", + "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_1, ))?; p.expect_end_eventually_with(")' branch\r\n")?; @@ -319,7 +319,7 @@ mod when_main_branch_is_uptodate { )?; c.succeeds_with(0, false, Some(0))?; p.expect(&format!( - "checked out proposal as 'prs/{}(", + "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_3, ))?; p.expect_end_eventually_with(")' branch\r\n")?; @@ -526,7 +526,7 @@ mod when_main_branch_is_uptodate { )?; c.succeeds_with(0, false, Some(0))?; p.expect(&format!( - "checked out proposal as 'prs/{}(", + "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_4, ))?; p.expect_end_eventually_with(")' branch\r\n")?; @@ -773,7 +773,7 @@ mod when_main_branch_is_uptodate { )?; c.succeeds_with(0, false, Some(0))?; p.expect(&format!( - "checked out proposal as 'prs/{}(", + "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_1, ))?; p.expect_end_eventually_with(")' branch\r\n")?; -- cgit v1.2.3