diff options
Diffstat (limited to 'src/bin/git_remote_nostr/main.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index ed9fe9d..e4f97c7 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs | |||
| @@ -15,7 +15,7 @@ use std::{ | |||
| 15 | use anyhow::{bail, Context, Result}; | 15 | use anyhow::{bail, Context, Result}; |
| 16 | use client::{consolidate_fetch_reports, get_repo_ref_from_cache, Connect}; | 16 | use client::{consolidate_fetch_reports, get_repo_ref_from_cache, Connect}; |
| 17 | use git::{nostr_url::NostrUrlDecoded, RepoActions}; | 17 | use git::{nostr_url::NostrUrlDecoded, RepoActions}; |
| 18 | use ngit::{client, git, login}; | 18 | use ngit::{client, git, login::existing::load_existing_login}; |
| 19 | use nostr::nips::nip01::Coordinate; | 19 | use nostr::nips::nip01::Coordinate; |
| 20 | use utils::read_line; | 20 | use utils::read_line; |
| 21 | 21 | ||
| @@ -36,38 +36,17 @@ async fn main() -> Result<()> { | |||
| 36 | 36 | ||
| 37 | let mut client = Client::default(); | 37 | let mut client = Client::default(); |
| 38 | 38 | ||
| 39 | if git_repo | 39 | if let Ok((signer, _, _)) = |
| 40 | .get_git_config_item("nostr.npub", None) | 40 | load_existing_login(&Some(&git_repo), &None, &None, &None, None, true, false).await |
| 41 | .is_ok_and(|x| x.is_some()) | ||
| 42 | && (git_repo | ||
| 43 | .get_git_config_item("nostr.nsec", None) | ||
| 44 | .is_ok_and(|x| x.is_some()) | ||
| 45 | || (git_repo | ||
| 46 | .get_git_config_item("nostr.bunker-uri", None) | ||
| 47 | .is_ok_and(|x| x.is_some()) | ||
| 48 | && git_repo | ||
| 49 | .get_git_config_item("nostr.bunker-app-key", None) | ||
| 50 | .is_ok_and(|x| x.is_some()))) | ||
| 51 | { | 41 | { |
| 52 | if let Ok((signer, _)) = login::launch( | 42 | // signer for to respond to relay auth request |
| 53 | &git_repo, | 43 | client.set_signer(signer).await; |
| 54 | &None, | ||
| 55 | &None, | ||
| 56 | &None, | ||
| 57 | &None, | ||
| 58 | Some(&client), | ||
| 59 | false, | ||
| 60 | true, | ||
| 61 | ) | ||
| 62 | .await | ||
| 63 | { | ||
| 64 | client.set_signer(signer).await; | ||
| 65 | }; | ||
| 66 | } | 44 | } |
| 67 | 45 | ||
| 68 | fetching_with_report_for_helper(git_repo_path, &client, &decoded_nostr_url.coordinates).await?; | 46 | fetching_with_report_for_helper(git_repo_path, &client, &decoded_nostr_url.coordinates).await?; |
| 69 | 47 | ||
| 70 | let repo_ref = get_repo_ref_from_cache(git_repo_path, &decoded_nostr_url.coordinates).await?; | 48 | let repo_ref = |
| 49 | get_repo_ref_from_cache(Some(git_repo_path), &decoded_nostr_url.coordinates).await?; | ||
| 71 | 50 | ||
| 72 | let stdin = io::stdin(); | 51 | let stdin = io::stdin(); |
| 73 | let mut line = String::new(); | 52 | let mut line = String::new(); |
| @@ -170,7 +149,7 @@ async fn fetching_with_report_for_helper( | |||
| 170 | let term = console::Term::stderr(); | 149 | let term = console::Term::stderr(); |
| 171 | term.write_line("nostr: fetching...")?; | 150 | term.write_line("nostr: fetching...")?; |
| 172 | let (relay_reports, progress_reporter) = client | 151 | let (relay_reports, progress_reporter) = client |
| 173 | .fetch_all(git_repo_path, repo_coordinates, &HashSet::new()) | 152 | .fetch_all(Some(git_repo_path), repo_coordinates, &HashSet::new()) |
| 174 | .await?; | 153 | .await?; |
| 175 | if !relay_reports.iter().any(std::result::Result::is_err) { | 154 | if !relay_reports.iter().any(std::result::Result::is_err) { |
| 176 | let _ = progress_reporter.clear(); | 155 | let _ = progress_reporter.clear(); |