From 5618fd9883d45de1443a40abada944cbe3bb8dfd Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 9 Aug 2024 08:35:53 +0100 Subject: feat(remote): `push` new proposal issue new proposal when new branch is pushed into `prs/*` namespace, which doesn't match an existing proposal --- src/git_remote_helper.rs | 20 ++++++++++++++++++-- src/sub_commands/send.rs | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs index 6997dfa..97db69a 100644 --- a/src/git_remote_helper.rs +++ b/src/git_remote_helper.rs @@ -814,8 +814,24 @@ async fn push( rejected_proposal_refspecs.push(refspec.to_string()); } } else { - // TODO new proposal / proposal no longer open - // / we couldn't + // TODO new proposal / couldn't find exisiting proposal + let (_, main_tip) = git_repo.get_main_or_master_branch()?; + let (mut ahead, _) = + git_repo.get_commits_ahead_behind(&main_tip, &tip_of_pushed_branch)?; + ahead.reverse(); + for patch in generate_cover_letter_and_patch_events( + None, + git_repo, + &ahead, + &signer, + repo_ref, + &None, + &[], + ) + .await? + { + events.push(patch); + } } } } diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index f492734..a005bd7 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -648,7 +648,11 @@ pub async fn generate_cover_letter_and_patch_events( vec![ Tag::custom( nostr::TagKind::Custom(std::borrow::Cow::Borrowed("branch-name")), - vec![branch_name], + vec![if let Some(branch_name) = branch_name.strip_prefix("prs/") { + branch_name.to_string() + } else { + branch_name + }], ), ] } @@ -687,7 +691,13 @@ pub async fn generate_cover_letter_and_patch_events( && !branch_name.eq("origin/main") && !branch_name.eq("origin/master") { - Some(branch_name) + Some( + if let Some(branch_name) = branch_name.strip_prefix("prs/") { + branch_name.to_string() + } else { + branch_name + }, + ) } else { None } -- cgit v1.2.3