diff options
Diffstat (limited to 'src/bin/git_remote_nostr/fetch.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/fetch.rs | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index f591fed..0a98db2 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use std::io::Stdin; | 1 | use std::io::Stdin; |
| 2 | 2 | ||
| 3 | use anyhow::{bail, Result}; | 3 | use anyhow::{anyhow, bail, Result}; |
| 4 | use auth_git2::GitAuthenticator; | 4 | use auth_git2::GitAuthenticator; |
| 5 | use git2::Repository; | 5 | use git2::Repository; |
| 6 | use ngit::{ | 6 | use ngit::{ |
| @@ -15,8 +15,8 @@ use ngit::{ | |||
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| 17 | use crate::utils::{ | 17 | use crate::utils::{ |
| 18 | find_proposal_and_patches_by_branch_name, get_oids_from_fetch_batch, get_open_proposals, | 18 | error_is_not_authentication_failure, find_proposal_and_patches_by_branch_name, |
| 19 | get_read_protocols_to_try, join_with_and, | 19 | get_oids_from_fetch_batch, get_open_proposals, get_read_protocols_to_try, join_with_and, |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | pub async fn run_fetch( | 22 | pub async fn run_fetch( |
| @@ -136,6 +136,10 @@ fn fetch_from_git_server( | |||
| 136 | format!("fetch: {formatted_url} failed over {protocol}: {error}").as_str(), | 136 | format!("fetch: {formatted_url} failed over {protocol}: {error}").as_str(), |
| 137 | )?; | 137 | )?; |
| 138 | failed_protocols.push(protocol); | 138 | failed_protocols.push(protocol); |
| 139 | if protocol == &ServerProtocol::Ssh && error_is_not_authentication_failure(&error) { | ||
| 140 | // authenticated by failed to complete request | ||
| 141 | break; | ||
| 142 | } | ||
| 139 | } else { | 143 | } else { |
| 140 | success = true; | 144 | success = true; |
| 141 | if !failed_protocols.is_empty() { | 145 | if !failed_protocols.is_empty() { |
| @@ -143,19 +147,22 @@ fn fetch_from_git_server( | |||
| 143 | } | 147 | } |
| 144 | } | 148 | } |
| 145 | } | 149 | } |
| 146 | if !success { | 150 | if success { |
| 147 | if decoded_nostr_url.protocol.is_some() { | 151 | Ok(()) |
| 148 | term.write_line( | 152 | } else { |
| 149 | "fetch: protocol override in nostr url so not attempting with any other protocols", | 153 | let error = anyhow!( |
| 150 | )?; | 154 | "{} failed over {}{}", |
| 151 | } | ||
| 152 | bail!( | ||
| 153 | "{} failed over {}", | ||
| 154 | server_url.domain(), | 155 | server_url.domain(), |
| 155 | join_with_and(&failed_protocols) | 156 | join_with_and(&failed_protocols), |
| 157 | if decoded_nostr_url.protocol.is_some() { | ||
| 158 | " and nostr url contains protocol override so no other protocols were attempted" | ||
| 159 | } else { | ||
| 160 | "" | ||
| 161 | }, | ||
| 156 | ); | 162 | ); |
| 163 | term.write_line(format!("fetch: {error}").as_str())?; | ||
| 164 | Err(error) | ||
| 157 | } | 165 | } |
| 158 | Ok(()) | ||
| 159 | } | 166 | } |
| 160 | 167 | ||
| 161 | fn fetch_from_git_server_url( | 168 | fn fetch_from_git_server_url( |