upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr/push.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-05-23 10:01:29 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-05-23 10:01:29 +0100
commit686604665395385600ef8f1b5238a775249552a1 (patch)
tree56a4c7a956e14dfbcdd4a518096968abc69583a6 /src/bin/git_remote_nostr/push.rs
parentcc9a3a1d8526373625246504f72f338fd89c8d8b (diff)
feat: only try http(s) for ngit-relays
otherwise it tries all the protocols and reprots on each
Diffstat (limited to 'src/bin/git_remote_nostr/push.rs')
-rw-r--r--src/bin/git_remote_nostr/push.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 4eae92f..a34d729 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -27,7 +27,7 @@ use ngit::{
27 }, 27 },
28 git_events::{self, event_to_cover_letter, get_event_root}, 28 git_events::{self, event_to_cover_letter, get_event_root},
29 login::{self, user::UserRef}, 29 login::{self, user::UserRef},
30 repo_ref::{self, get_repo_config_from_yaml}, 30 repo_ref::{self, get_repo_config_from_yaml, is_ngit_relay},
31 repo_state, 31 repo_state,
32}; 32};
33use nostr::nips::nip10::Marker; 33use nostr::nips::nip10::Marker;
@@ -49,6 +49,7 @@ use crate::{
49 }, 49 },
50}; 50};
51 51
52#[allow(clippy::too_many_lines)]
52pub async fn run_push( 53pub async fn run_push(
53 git_repo: &Repo, 54 git_repo: &Repo,
54 repo_ref: &RepoRef, 55 repo_ref: &RepoRef,
@@ -79,6 +80,7 @@ pub async fn run_push(
79 git_repo, 80 git_repo,
80 &repo_ref.git_server, 81 &repo_ref.git_server,
81 &repo_ref.to_nostr_git_url(&None), 82 &repo_ref.to_nostr_git_url(&None),
83 &repo_ref.ngit_relays(),
82 ) 84 )
83 }); 85 });
84 86
@@ -161,6 +163,7 @@ pub async fn run_push(
161 &repo_ref.to_nostr_git_url(&None), 163 &repo_ref.to_nostr_git_url(&None),
162 &remote_refspecs, 164 &remote_refspecs,
163 &term, 165 &term,
166 is_ngit_relay(&git_server_url, &repo_ref.ngit_relays()),
164 ); 167 );
165 } 168 }
166 } 169 }
@@ -412,9 +415,11 @@ fn push_to_remote(
412 decoded_nostr_url: &NostrUrlDecoded, 415 decoded_nostr_url: &NostrUrlDecoded,
413 remote_refspecs: &[String], 416 remote_refspecs: &[String],
414 term: &Term, 417 term: &Term,
418 is_ngit_relay: bool,
415) -> Result<()> { 419) -> Result<()> {
416 let server_url = git_server_url.parse::<CloneUrl>()?; 420 let server_url = git_server_url.parse::<CloneUrl>()?;
417 let protocols_to_attempt = get_write_protocols_to_try(git_repo, &server_url, decoded_nostr_url); 421 let protocols_to_attempt =
422 get_write_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_ngit_relay);
418 423
419 let mut failed_protocols = vec![]; 424 let mut failed_protocols = vec![];
420 let mut success = false; 425 let mut success = false;