upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib/push.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/push.rs')
-rw-r--r--src/lib/push.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/push.rs b/src/lib/push.rs
index 274a16a..5544066 100644
--- a/src/lib/push.rs
+++ b/src/lib/push.rs
@@ -49,6 +49,7 @@ pub fn push_to_remote(
49 remote_refspecs: &[String], 49 remote_refspecs: &[String],
50 term: &Term, 50 term: &Term,
51 is_grasp_server: bool, 51 is_grasp_server: bool,
52 git_server_push_options: &[&str],
52) -> Result<HashMap<String, Option<String>>> { 53) -> Result<HashMap<String, Option<String>>> {
53 let server_url = git_server_url.parse::<CloneUrl>()?; 54 let server_url = git_server_url.parse::<CloneUrl>()?;
54 let protocols_to_attempt = 55 let protocols_to_attempt =
@@ -69,6 +70,7 @@ pub fn push_to_remote(
69 decoded_nostr_url.ssh_key_file_path().as_ref(), 70 decoded_nostr_url.ssh_key_file_path().as_ref(),
70 remote_refspecs, 71 remote_refspecs,
71 term, 72 term,
73 git_server_push_options,
72 ) { 74 ) {
73 Err(error) => { 75 Err(error) => {
74 term.write_line( 76 term.write_line(
@@ -149,6 +151,7 @@ pub fn push_to_remote_url(
149 ssh_key_file: Option<&String>, 151 ssh_key_file: Option<&String>,
150 remote_refspecs: &[String], 152 remote_refspecs: &[String],
151 term: &Term, 153 term: &Term,
154 git_server_push_options: &[&str],
152) -> Result<HashMap<String, Option<String>>> { 155) -> Result<HashMap<String, Option<String>>> {
153 let git_config = git_repo.git_repo.config()?; 156 let git_config = git_repo.git_repo.config()?;
154 let mut git_server_remote = git_repo.git_repo.remote_anonymous(git_server_url)?; 157 let mut git_server_remote = git_repo.git_repo.remote_anonymous(git_server_url)?;
@@ -262,6 +265,9 @@ pub fn push_to_remote_url(
262 } 265 }
263 }); 266 });
264 push_options.remote_callbacks(remote_callbacks); 267 push_options.remote_callbacks(remote_callbacks);
268 if !git_server_push_options.is_empty() {
269 push_options.remote_push_options(git_server_push_options);
270 }
265 git_server_remote.push(remote_refspecs, Some(&mut push_options))?; 271 git_server_remote.push(remote_refspecs, Some(&mut push_options))?;
266 let _ = git_server_remote.disconnect(); 272 let _ = git_server_remote.disconnect();
267 let reporter = push_reporter.lock().unwrap(); 273 let reporter = push_reporter.lock().unwrap();
@@ -417,6 +423,7 @@ pub async fn select_servers_push_refs_and_generate_pr_or_pr_update_event(
417 signer: &Arc<dyn NostrSigner>, 423 signer: &Arc<dyn NostrSigner>,
418 interactive: bool, 424 interactive: bool,
419 term: &Term, 425 term: &Term,
426 git_server_push_options: &[&str],
420) -> Result<Vec<Event>> { 427) -> Result<Vec<Event>> {
421 let git_repo_path = git_repo.get_path()?; 428 let git_repo_path = git_repo.get_path()?;
422 let mut to_try = vec![]; 429 let mut to_try = vec![];
@@ -483,6 +490,7 @@ pub async fn select_servers_push_refs_and_generate_pr_or_pr_update_event(
483 git_ref.clone(), 490 git_ref.clone(),
484 signer, 491 signer,
485 term, 492 term,
493 git_server_push_options,
486 ) 494 )
487 .await?; 495 .await?;
488 for url in to_try { 496 for url in to_try {
@@ -717,6 +725,7 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event(
717 git_ref: Option<String>, 725 git_ref: Option<String>,
718 signer: &Arc<dyn NostrSigner>, 726 signer: &Arc<dyn NostrSigner>,
719 term: &Term, 727 term: &Term,
728 git_server_push_options: &[&str],
720) -> Result<(Option<Vec<Event>>, Vec<(String, Result<()>)>)> { 729) -> Result<(Option<Vec<Event>>, Vec<(String, Result<()>)>)> {
721 let mut responses: Vec<(String, Result<()>)> = vec![]; 730 let mut responses: Vec<(String, Result<()>)> = vec![];
722 731
@@ -747,7 +756,14 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event(
747 let refspec = format!("{tip}:{git_ref_used}"); 756 let refspec = format!("{tip}:{git_ref_used}");
748 757
749 let res = if is_grasp_server_clone_url(clone_url) { 758 let res = if is_grasp_server_clone_url(clone_url) {
750 push_to_remote_url(git_repo, clone_url, None, &[refspec], term) 759 push_to_remote_url(
760 git_repo,
761 clone_url,
762 None,
763 &[refspec],
764 term,
765 git_server_push_options,
766 )
751 } else { 767 } else {
752 // anticipated only when pushing to user's own repo or a personal-fork with 768 // anticipated only when pushing to user's own repo or a personal-fork with
753 // non-grasp git servers. this is used to extract prefered protocols / ssh 769 // non-grasp git servers. this is used to extract prefered protocols / ssh
@@ -769,6 +785,7 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event(
769 &[refspec], 785 &[refspec],
770 term, 786 term,
771 false, 787 false,
788 git_server_push_options,
772 ) 789 )
773 }; 790 };
774 791