upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-08-05 11:38:09 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-08-06 16:00:58 +0100
commit29f61ffdf155ea88b8d9aec23d28cf70baba577e (patch)
treec235805b72d601ad8f9898f79c337fbb3d91b077 /src
parentdee39c39116773fde22c4fe30a87d54d1d3658e2 (diff)
feat(send): custom ref for PR clone url
allow specifying ref for pushing PR to custom clone url
Diffstat (limited to 'src')
-rw-r--r--src/bin/git_remote_nostr/push.rs1
-rw-r--r--src/bin/ngit/sub_commands/send.rs14
-rw-r--r--src/lib/push.rs8
3 files changed, 21 insertions, 2 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 4552b91..f98e792 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -482,6 +482,7 @@ async fn generate_patches_or_pr_event_or_pr_updates(
482 root_proposal, 482 root_proposal,
483 &None, 483 &None,
484 &repo_grasp_clone_urls, 484 &repo_grasp_clone_urls,
485 None,
485 signer, 486 signer,
486 term, 487 term,
487 ) 488 )
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs
index 69ad1e6..609812b 100644
--- a/src/bin/ngit/sub_commands/send.rs
+++ b/src/bin/ngit/sub_commands/send.rs
@@ -208,6 +208,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
208 } 208 }
209 let mut to_try = repo_grasp_clone_urls.clone(); 209 let mut to_try = repo_grasp_clone_urls.clone();
210 let mut tried = vec![]; 210 let mut tried = vec![];
211 let mut git_ref = None;
211 loop { 212 loop {
212 let (events, _server_responses) = push_refs_and_generate_pr_or_pr_update_event( 213 let (events, _server_responses) = push_refs_and_generate_pr_or_pr_update_event(
213 &git_repo, 214 &git_repo,
@@ -217,6 +218,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
217 root_proposal.as_ref(), 218 root_proposal.as_ref(),
218 &cover_letter_title_description, 219 &cover_letter_title_description,
219 &repo_grasp_clone_urls, 220 &repo_grasp_clone_urls,
221 git_ref.clone(),
220 &signer, 222 &signer,
221 &console::Term::stdout(), 223 &console::Term::stdout(),
222 ) 224 )
@@ -235,7 +237,17 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
235 .clone(); 237 .clone();
236 if CloneUrl::from_str(&clone_url).is_ok() { 238 if CloneUrl::from_str(&clone_url).is_ok() {
237 to_try.push(clone_url); 239 to_try.push(clone_url);
238 // TODO customise ref to push 240 let mut git_ref_or_branch_name = Interactor::default()
241 .input(
242 PromptInputParms::default()
243 .with_prompt("ref / branch name")
244 .with_default(git_ref.unwrap_or("refs/nostr/<event-id>".to_string())),
245 )?
246 .clone();
247 if !git_ref_or_branch_name.starts_with("refs/") {
248 git_ref_or_branch_name = format!("refs/heads/{git_ref_or_branch_name}");
249 }
250 git_ref = Some(git_ref_or_branch_name);
239 } else { 251 } else {
240 println!("invalid clone url"); 252 println!("invalid clone url");
241 } 253 }
diff --git a/src/lib/push.rs b/src/lib/push.rs
index 4c2d8f1..c202397 100644
--- a/src/lib/push.rs
+++ b/src/lib/push.rs
@@ -330,6 +330,7 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event(
330 root_proposal: Option<&Event>, 330 root_proposal: Option<&Event>,
331 title_description_overide: &Option<(String, String)>, 331 title_description_overide: &Option<(String, String)>,
332 servers: &[String], 332 servers: &[String],
333 git_ref: Option<String>,
333 signer: &Arc<dyn NostrSigner>, 334 signer: &Arc<dyn NostrSigner>,
334 term: &Term, 335 term: &Term,
335) -> Result<(Option<Vec<Event>>, Vec<(String, Result<()>)>)> { 336) -> Result<(Option<Vec<Event>>, Vec<(String, Result<()>)>)> {
@@ -352,7 +353,12 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event(
352 )? 353 )?
353 }; 354 };
354 355
355 let refspec = format!("{}:refs/nostr/{}", tip, draft_pr_event.id()); 356 let git_ref_used = git_ref
357 .clone()
358 .unwrap_or("refs/nostr/<event-id>".to_string())
359 .replace("<event-id>", &draft_pr_event.id().to_string());
360
361 let refspec = format!("{tip}:{git_ref_used}");
356 362
357 if let Err(error) = push_to_remote_url(git_repo, clone_url, &[refspec], term) { 363 if let Err(error) = push_to_remote_url(git_repo, clone_url, &[refspec], term) {
358 term.write_line( 364 term.write_line(