upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr/fetch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/git_remote_nostr/fetch.rs')
-rw-r--r--src/bin/git_remote_nostr/fetch.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs
index 33fd959..fed9925 100644
--- a/src/bin/git_remote_nostr/fetch.rs
+++ b/src/bin/git_remote_nostr/fetch.rs
@@ -22,6 +22,7 @@ use ngit::{
22use crate::utils::{ 22use crate::utils::{
23 fetch_or_list_error_is_not_authentication_failure, find_proposal_and_patches_by_branch_name, 23 fetch_or_list_error_is_not_authentication_failure, find_proposal_and_patches_by_branch_name,
24 get_oids_from_fetch_batch, get_open_proposals, get_read_protocols_to_try, join_with_and, 24 get_oids_from_fetch_batch, get_open_proposals, get_read_protocols_to_try, join_with_and,
25 set_protocol_preference, Direction,
25}; 26};
26 27
27pub async fn run_fetch( 28pub async fn run_fetch(
@@ -46,7 +47,7 @@ pub async fn run_fetch(
46 for git_server_url in &repo_ref.git_server { 47 for git_server_url in &repo_ref.git_server {
47 let term = console::Term::stderr(); 48 let term = console::Term::stderr();
48 if let Err(error) = fetch_from_git_server( 49 if let Err(error) = fetch_from_git_server(
49 &git_repo.git_repo, 50 git_repo,
50 &oids_from_git_servers, 51 &oids_from_git_servers,
51 git_server_url, 52 git_server_url,
52 decoded_nostr_url, 53 decoded_nostr_url,
@@ -112,7 +113,7 @@ pub async fn run_fetch(
112} 113}
113 114
114fn fetch_from_git_server( 115fn fetch_from_git_server(
115 git_repo: &Repository, 116 git_repo: &Repo,
116 oids: &[String], 117 oids: &[String],
117 git_server_url: &str, 118 git_server_url: &str,
118 decoded_nostr_url: &NostrUrlDecoded, 119 decoded_nostr_url: &NostrUrlDecoded,
@@ -120,7 +121,7 @@ fn fetch_from_git_server(
120) -> Result<()> { 121) -> Result<()> {
121 let server_url = git_server_url.parse::<CloneUrl>()?; 122 let server_url = git_server_url.parse::<CloneUrl>()?;
122 123
123 let protocols_to_attempt = get_read_protocols_to_try(&server_url, decoded_nostr_url); 124 let protocols_to_attempt = get_read_protocols_to_try(git_repo, &server_url, decoded_nostr_url);
124 125
125 let mut failed_protocols = vec![]; 126 let mut failed_protocols = vec![];
126 let mut success = false; 127 let mut success = false;
@@ -131,7 +132,7 @@ fn fetch_from_git_server(
131 132
132 let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; 133 let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?;
133 let res = fetch_from_git_server_url( 134 let res = fetch_from_git_server_url(
134 git_repo, 135 &git_repo.git_repo,
135 oids, 136 oids,
136 &formatted_url, 137 &formatted_url,
137 [ServerProtocol::UnauthHttps, ServerProtocol::UnauthHttp].contains(protocol), 138 [ServerProtocol::UnauthHttps, ServerProtocol::UnauthHttp].contains(protocol),
@@ -152,6 +153,7 @@ fn fetch_from_git_server(
152 success = true; 153 success = true;
153 if !failed_protocols.is_empty() { 154 if !failed_protocols.is_empty() {
154 term.write_line(format!("fetch: succeeded over {protocol}").as_str())?; 155 term.write_line(format!("fetch: succeeded over {protocol}").as_str())?;
156 let _ = set_protocol_preference(git_repo, protocol, &server_url, &Direction::Push);
155 } 157 }
156 break; 158 break;
157 } 159 }