diff options
Diffstat (limited to 'src/bin/git_remote_nostr')
| -rw-r--r-- | src/bin/git_remote_nostr/fetch.rs | 8 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/list.rs | 24 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 24 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/utils.rs | 8 |
4 files changed, 32 insertions, 32 deletions
diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index adc68b3..b191850 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs | |||
| @@ -18,7 +18,7 @@ use ngit::{ | |||
| 18 | }, | 18 | }, |
| 19 | git_events::tag_value, | 19 | git_events::tag_value, |
| 20 | login::get_curent_user, | 20 | login::get_curent_user, |
| 21 | repo_ref::{RepoRef, is_ngit_relay}, | 21 | repo_ref::{RepoRef, is_grasp_server}, |
| 22 | }; | 22 | }; |
| 23 | use nostr::nips::nip19; | 23 | use nostr::nips::nip19; |
| 24 | use nostr_sdk::{Event, ToBech32}; | 24 | use nostr_sdk::{Event, ToBech32}; |
| @@ -54,7 +54,7 @@ pub async fn run_fetch( | |||
| 54 | git_server_url, | 54 | git_server_url, |
| 55 | &repo_ref.to_nostr_git_url(&None), | 55 | &repo_ref.to_nostr_git_url(&None), |
| 56 | &term, | 56 | &term, |
| 57 | is_ngit_relay(git_server_url, &repo_ref.ngit_relays()), | 57 | is_grasp_server(git_server_url, &repo_ref.grasp_servers()), |
| 58 | ) { | 58 | ) { |
| 59 | errors.push(error); | 59 | errors.push(error); |
| 60 | } else { | 60 | } else { |
| @@ -164,7 +164,7 @@ pub fn fetch_from_git_server( | |||
| 164 | git_server_url: &str, | 164 | git_server_url: &str, |
| 165 | decoded_nostr_url: &NostrUrlDecoded, | 165 | decoded_nostr_url: &NostrUrlDecoded, |
| 166 | term: &console::Term, | 166 | term: &console::Term, |
| 167 | is_ngit_relay: bool, | 167 | is_grasp_server: bool, |
| 168 | ) -> Result<()> { | 168 | ) -> Result<()> { |
| 169 | let already_have_oids = oids | 169 | let already_have_oids = oids |
| 170 | .iter() | 170 | .iter() |
| @@ -176,7 +176,7 @@ pub fn fetch_from_git_server( | |||
| 176 | let server_url = git_server_url.parse::<CloneUrl>()?; | 176 | let server_url = git_server_url.parse::<CloneUrl>()?; |
| 177 | 177 | ||
| 178 | let protocols_to_attempt = | 178 | let protocols_to_attempt = |
| 179 | get_read_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_ngit_relay); | 179 | get_read_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_grasp_server); |
| 180 | 180 | ||
| 181 | let mut failed_protocols = vec![]; | 181 | let mut failed_protocols = vec![]; |
| 182 | let mut success = false; | 182 | let mut success = false; |
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index c27e4d2..b9fb0c0 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs | |||
| @@ -13,7 +13,7 @@ use ngit::{ | |||
| 13 | }, | 13 | }, |
| 14 | git_events::event_to_cover_letter, | 14 | git_events::event_to_cover_letter, |
| 15 | login::get_curent_user, | 15 | login::get_curent_user, |
| 16 | repo_ref::{self, is_ngit_relay}, | 16 | repo_ref::{self, is_grasp_server}, |
| 17 | }; | 17 | }; |
| 18 | use nostr_sdk::hashes::sha1::Hash as Sha1Hash; | 18 | use nostr_sdk::hashes::sha1::Hash as Sha1Hash; |
| 19 | use repo_ref::RepoRef; | 19 | use repo_ref::RepoRef; |
| @@ -41,12 +41,12 @@ pub async fn run_list( | |||
| 41 | git_repo, | 41 | git_repo, |
| 42 | &repo_ref.git_server, | 42 | &repo_ref.git_server, |
| 43 | &repo_ref.to_nostr_git_url(&None), | 43 | &repo_ref.to_nostr_git_url(&None), |
| 44 | &repo_ref.ngit_relays(), | 44 | &repo_ref.grasp_servers(), |
| 45 | ); | 45 | ); |
| 46 | 46 | ||
| 47 | let mut state = if let Some(nostr_state) = nostr_state { | 47 | let mut state = if let Some(nostr_state) = nostr_state { |
| 48 | for (name, value) in &nostr_state.state { | 48 | for (name, value) in &nostr_state.state { |
| 49 | for (url, (remote_state, _is_ngit_relay)) in &remote_states { | 49 | for (url, (remote_state, _is_grasp_server)) in &remote_states { |
| 50 | let remote_name = get_short_git_server_name(git_repo, url); | 50 | let remote_name = get_short_git_server_name(git_repo, url); |
| 51 | if let Some(remote_value) = remote_state.get(name) { | 51 | if let Some(remote_value) = remote_state.get(name) { |
| 52 | if value.ne(remote_value) { | 52 | if value.ne(remote_value) { |
| @@ -74,7 +74,7 @@ pub async fn run_list( | |||
| 74 | } | 74 | } |
| 75 | nostr_state.state | 75 | nostr_state.state |
| 76 | } else { | 76 | } else { |
| 77 | let (state, _is_ngit_relay) = repo_ref | 77 | let (state, _is_grasp_server) = repo_ref |
| 78 | .git_server | 78 | .git_server |
| 79 | .iter() | 79 | .iter() |
| 80 | .filter_map(|server| remote_states.get(server)) | 80 | .filter_map(|server| remote_states.get(server)) |
| @@ -122,7 +122,7 @@ async fn get_open_and_draft_proposals_state( | |||
| 122 | 122 | ||
| 123 | // without trusting commit_id we must apply each patch which requires the oid of | 123 | // without trusting commit_id we must apply each patch which requires the oid of |
| 124 | // the parent so we much do a fetch | 124 | // the parent so we much do a fetch |
| 125 | for (git_server_url, (oids_from_git_servers, is_ngit_relay)) in remote_states { | 125 | for (git_server_url, (oids_from_git_servers, is_grasp_server)) in remote_states { |
| 126 | if fetch_from_git_server( | 126 | if fetch_from_git_server( |
| 127 | git_repo, | 127 | git_repo, |
| 128 | &oids_from_git_servers | 128 | &oids_from_git_servers |
| @@ -133,7 +133,7 @@ async fn get_open_and_draft_proposals_state( | |||
| 133 | git_server_url, | 133 | git_server_url, |
| 134 | &repo_ref.to_nostr_git_url(&None), | 134 | &repo_ref.to_nostr_git_url(&None), |
| 135 | term, | 135 | term, |
| 136 | *is_ngit_relay, | 136 | *is_grasp_server, |
| 137 | ) | 137 | ) |
| 138 | .is_ok() | 138 | .is_ok() |
| 139 | { | 139 | { |
| @@ -178,18 +178,18 @@ pub fn list_from_remotes( | |||
| 178 | git_repo: &Repo, | 178 | git_repo: &Repo, |
| 179 | git_servers: &Vec<String>, | 179 | git_servers: &Vec<String>, |
| 180 | decoded_nostr_url: &NostrUrlDecoded, | 180 | decoded_nostr_url: &NostrUrlDecoded, |
| 181 | ngit_relays: &[String], | 181 | grasp_servers: &[String], |
| 182 | ) -> HashMap<String, (HashMap<String, String>, bool)> { | 182 | ) -> HashMap<String, (HashMap<String, String>, bool)> { |
| 183 | let mut remote_states = HashMap::new(); | 183 | let mut remote_states = HashMap::new(); |
| 184 | let mut errors = HashMap::new(); | 184 | let mut errors = HashMap::new(); |
| 185 | for url in git_servers { | 185 | for url in git_servers { |
| 186 | let is_ngit_relay = is_ngit_relay(url, ngit_relays); | 186 | let is_grasp_server = is_grasp_server(url, grasp_servers); |
| 187 | match list_from_remote(term, git_repo, url, decoded_nostr_url, is_ngit_relay) { | 187 | match list_from_remote(term, git_repo, url, decoded_nostr_url, is_grasp_server) { |
| 188 | Err(error) => { | 188 | Err(error) => { |
| 189 | errors.insert(url, error); | 189 | errors.insert(url, error); |
| 190 | } | 190 | } |
| 191 | Ok(state) => { | 191 | Ok(state) => { |
| 192 | remote_states.insert(url.to_string(), (state, is_ngit_relay)); | 192 | remote_states.insert(url.to_string(), (state, is_grasp_server)); |
| 193 | } | 193 | } |
| 194 | } | 194 | } |
| 195 | } | 195 | } |
| @@ -201,11 +201,11 @@ pub fn list_from_remote( | |||
| 201 | git_repo: &Repo, | 201 | git_repo: &Repo, |
| 202 | git_server_url: &str, | 202 | git_server_url: &str, |
| 203 | decoded_nostr_url: &NostrUrlDecoded, | 203 | decoded_nostr_url: &NostrUrlDecoded, |
| 204 | is_ngit_relay: bool, | 204 | is_grasp_server: bool, |
| 205 | ) -> Result<HashMap<String, String>> { | 205 | ) -> Result<HashMap<String, String>> { |
| 206 | let server_url = git_server_url.parse::<CloneUrl>()?; | 206 | let server_url = git_server_url.parse::<CloneUrl>()?; |
| 207 | let protocols_to_attempt = | 207 | let protocols_to_attempt = |
| 208 | get_read_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_ngit_relay); | 208 | get_read_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_grasp_server); |
| 209 | 209 | ||
| 210 | let mut failed_protocols = vec![]; | 210 | let mut failed_protocols = vec![]; |
| 211 | let mut remote_state: Option<HashMap<String, String>> = None; | 211 | let mut remote_state: Option<HashMap<String, String>> = None; |
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 9e54ca7..04fc4d8 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -25,7 +25,7 @@ use ngit::{ | |||
| 25 | }, | 25 | }, |
| 26 | git_events::{self, event_to_cover_letter, get_event_root}, | 26 | git_events::{self, event_to_cover_letter, get_event_root}, |
| 27 | login::{self, user::UserRef}, | 27 | login::{self, user::UserRef}, |
| 28 | repo_ref::{self, get_repo_config_from_yaml, is_ngit_relay}, | 28 | repo_ref::{self, get_repo_config_from_yaml, is_grasp_server}, |
| 29 | repo_state, | 29 | repo_state, |
| 30 | }; | 30 | }; |
| 31 | use nostr::nips::nip10::Marker; | 31 | use nostr::nips::nip10::Marker; |
| @@ -79,7 +79,7 @@ pub async fn run_push( | |||
| 79 | git_repo, | 79 | git_repo, |
| 80 | &repo_ref.git_server, | 80 | &repo_ref.git_server, |
| 81 | &repo_ref.to_nostr_git_url(&None), | 81 | &repo_ref.to_nostr_git_url(&None), |
| 82 | &repo_ref.ngit_relays(), | 82 | &repo_ref.grasp_servers(), |
| 83 | ) | 83 | ) |
| 84 | }); | 84 | }); |
| 85 | 85 | ||
| @@ -92,7 +92,7 @@ pub async fn run_push( | |||
| 92 | .iter() | 92 | .iter() |
| 93 | .find(|&url| list_outputs.contains_key(url)) | 93 | .find(|&url| list_outputs.contains_key(url)) |
| 94 | { | 94 | { |
| 95 | let (state, _is_ngit_relay) = list_outputs.get(url).unwrap().to_owned(); | 95 | let (state, _is_grasp_server) = list_outputs.get(url).unwrap().to_owned(); |
| 96 | state | 96 | state |
| 97 | } else { | 97 | } else { |
| 98 | bail!( | 98 | bail!( |
| @@ -163,7 +163,7 @@ pub async fn run_push( | |||
| 163 | &repo_ref.to_nostr_git_url(&None), | 163 | &repo_ref.to_nostr_git_url(&None), |
| 164 | &remote_refspecs, | 164 | &remote_refspecs, |
| 165 | &term, | 165 | &term, |
| 166 | is_ngit_relay(&git_server_url, &repo_ref.ngit_relays()), | 166 | is_grasp_server(&git_server_url, &repo_ref.grasp_servers()), |
| 167 | ); | 167 | ); |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| @@ -429,11 +429,11 @@ fn push_to_remote( | |||
| 429 | decoded_nostr_url: &NostrUrlDecoded, | 429 | decoded_nostr_url: &NostrUrlDecoded, |
| 430 | remote_refspecs: &[String], | 430 | remote_refspecs: &[String], |
| 431 | term: &Term, | 431 | term: &Term, |
| 432 | is_ngit_relay: bool, | 432 | is_grasp_server: bool, |
| 433 | ) -> Result<()> { | 433 | ) -> Result<()> { |
| 434 | let server_url = git_server_url.parse::<CloneUrl>()?; | 434 | let server_url = git_server_url.parse::<CloneUrl>()?; |
| 435 | let protocols_to_attempt = | 435 | let protocols_to_attempt = |
| 436 | get_write_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_ngit_relay); | 436 | get_write_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_grasp_server); |
| 437 | 437 | ||
| 438 | let mut failed_protocols = vec![]; | 438 | let mut failed_protocols = vec![]; |
| 439 | let mut success = false; | 439 | let mut success = false; |
| @@ -726,8 +726,8 @@ fn create_rejected_refspecs_and_remotes_refspecs( | |||
| 726 | 726 | ||
| 727 | let mut rejected_refspecs: HashMapUrlRefspecs = HashMap::new(); | 727 | let mut rejected_refspecs: HashMapUrlRefspecs = HashMap::new(); |
| 728 | 728 | ||
| 729 | for (url, (remote_state, is_ngit_relay)) in list_outputs { | 729 | for (url, (remote_state, is_grasp_server)) in list_outputs { |
| 730 | let is_ngit_relay = is_ngit_relay.to_owned(); | 730 | let is_grasp_server = is_grasp_server.to_owned(); |
| 731 | let short_name = get_short_git_server_name(git_repo, url); | 731 | let short_name = get_short_git_server_name(git_repo, url); |
| 732 | let mut refspecs_for_remote = vec![]; | 732 | let mut refspecs_for_remote = vec![]; |
| 733 | for refspec in refspecs { | 733 | for refspec in refspecs { |
| @@ -788,7 +788,7 @@ fn create_rejected_refspecs_and_remotes_refspecs( | |||
| 788 | if ahead_of_nostr.is_empty() { | 788 | if ahead_of_nostr.is_empty() { |
| 789 | // ancestor of nostr and we are force pushing anyway... | 789 | // ancestor of nostr and we are force pushing anyway... |
| 790 | refspecs_for_remote.push(refspec.clone()); | 790 | refspecs_for_remote.push(refspec.clone()); |
| 791 | } else if is_ngit_relay { | 791 | } else if is_grasp_server { |
| 792 | // a grasp server can only be pushed to via nostr so can force push | 792 | // a grasp server can only be pushed to via nostr so can force push |
| 793 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); | 793 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); |
| 794 | } else { | 794 | } else { |
| @@ -807,7 +807,7 @@ fn create_rejected_refspecs_and_remotes_refspecs( | |||
| 807 | )?; | 807 | )?; |
| 808 | } | 808 | } |
| 809 | } | 809 | } |
| 810 | } else if is_ngit_relay { | 810 | } else if is_grasp_server { |
| 811 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); | 811 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); |
| 812 | } else { | 812 | } else { |
| 813 | // remote_value oid is not present locally | 813 | // remote_value oid is not present locally |
| @@ -842,7 +842,7 @@ fn create_rejected_refspecs_and_remotes_refspecs( | |||
| 842 | if ahead.is_empty() { | 842 | if ahead.is_empty() { |
| 843 | // can soft push | 843 | // can soft push |
| 844 | refspecs_for_remote.push(refspec.clone()); | 844 | refspecs_for_remote.push(refspec.clone()); |
| 845 | } else if is_ngit_relay { | 845 | } else if is_grasp_server { |
| 846 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); | 846 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); |
| 847 | } else { | 847 | } else { |
| 848 | // cant soft push | 848 | // cant soft push |
| @@ -858,7 +858,7 @@ fn create_rejected_refspecs_and_remotes_refspecs( | |||
| 858 | ).as_str(), | 858 | ).as_str(), |
| 859 | )?; | 859 | )?; |
| 860 | } | 860 | } |
| 861 | } else if is_ngit_relay { | 861 | } else if is_grasp_server { |
| 862 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); | 862 | refspecs_for_remote.push(ensure_force_push_refspec(refspec)); |
| 863 | } else { | 863 | } else { |
| 864 | // havn't fetched oid from remote | 864 | // havn't fetched oid from remote |
diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index ec6412b..f7e688e 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs | |||
| @@ -216,9 +216,9 @@ pub fn get_read_protocols_to_try( | |||
| 216 | git_repo: &Repo, | 216 | git_repo: &Repo, |
| 217 | server_url: &CloneUrl, | 217 | server_url: &CloneUrl, |
| 218 | decoded_nostr_url: &NostrUrlDecoded, | 218 | decoded_nostr_url: &NostrUrlDecoded, |
| 219 | is_ngit_relay: bool, | 219 | is_grasp_server: bool, |
| 220 | ) -> Vec<ServerProtocol> { | 220 | ) -> Vec<ServerProtocol> { |
| 221 | if is_ngit_relay { | 221 | if is_grasp_server { |
| 222 | if server_url.protocol() == ServerProtocol::Http { | 222 | if server_url.protocol() == ServerProtocol::Http { |
| 223 | vec![(ServerProtocol::UnauthHttp)] | 223 | vec![(ServerProtocol::UnauthHttp)] |
| 224 | } else { | 224 | } else { |
| @@ -269,9 +269,9 @@ pub fn get_write_protocols_to_try( | |||
| 269 | git_repo: &Repo, | 269 | git_repo: &Repo, |
| 270 | server_url: &CloneUrl, | 270 | server_url: &CloneUrl, |
| 271 | decoded_nostr_url: &NostrUrlDecoded, | 271 | decoded_nostr_url: &NostrUrlDecoded, |
| 272 | is_ngit_relay: bool, | 272 | is_grasp_server: bool, |
| 273 | ) -> Vec<ServerProtocol> { | 273 | ) -> Vec<ServerProtocol> { |
| 274 | if is_ngit_relay { | 274 | if is_grasp_server { |
| 275 | if server_url.protocol() == ServerProtocol::Http { | 275 | if server_url.protocol() == ServerProtocol::Http { |
| 276 | vec![(ServerProtocol::UnauthHttp)] | 276 | vec![(ServerProtocol::UnauthHttp)] |
| 277 | } else { | 277 | } else { |