diff options
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 8 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 3 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/list.rs | 6 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/login.rs | 11 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/send.rs | 7 |
5 files changed, 24 insertions, 11 deletions
diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index daa924f..29731e2 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs | |||
| @@ -14,7 +14,11 @@ use std::{ | |||
| 14 | use anyhow::{Context, Result, bail}; | 14 | use anyhow::{Context, Result, bail}; |
| 15 | use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache}; | 15 | use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache}; |
| 16 | use git::{RepoActions, nostr_url::NostrUrlDecoded}; | 16 | use git::{RepoActions, nostr_url::NostrUrlDecoded}; |
| 17 | use ngit::{client, git, login::existing::load_existing_login}; | 17 | use ngit::{ |
| 18 | client::{self, Params}, | ||
| 19 | git, | ||
| 20 | login::existing::load_existing_login, | ||
| 21 | }; | ||
| 18 | use nostr::nips::nip19::Nip19Coordinate; | 22 | use nostr::nips::nip19::Nip19Coordinate; |
| 19 | use utils::read_line; | 23 | use utils::read_line; |
| 20 | 24 | ||
| @@ -33,7 +37,7 @@ async fn main() -> Result<()> { | |||
| 33 | 37 | ||
| 34 | let git_repo_path = git_repo.get_path()?; | 38 | let git_repo_path = git_repo.get_path()?; |
| 35 | 39 | ||
| 36 | let mut client = Client::default(); | 40 | let mut client = Client::new(Params::with_git_config_relay_defaults(&Some(&git_repo))); |
| 37 | 41 | ||
| 38 | if let Ok((signer, _, _)) = load_existing_login( | 42 | if let Ok((signer, _, _)) = load_existing_login( |
| 39 | &Some(&git_repo), | 43 | &Some(&git_repo), |
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 3c58a52..ee5f1ab 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -4,6 +4,7 @@ use anyhow::{Context, Result}; | |||
| 4 | use console::{Style, Term}; | 4 | use console::{Style, Term}; |
| 5 | use ngit::{ | 5 | use ngit::{ |
| 6 | cli_interactor::PromptConfirmParms, | 6 | cli_interactor::PromptConfirmParms, |
| 7 | client::Params, | ||
| 7 | git::nostr_url::{NostrUrlDecoded, save_nip05_to_git_config_cache}, | 8 | git::nostr_url::{NostrUrlDecoded, save_nip05_to_git_config_cache}, |
| 8 | }; | 9 | }; |
| 9 | use nostr::{ | 10 | use nostr::{ |
| @@ -68,7 +69,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 68 | // TODO: check for empty repo | 69 | // TODO: check for empty repo |
| 69 | // TODO: check for existing maintaiers file | 70 | // TODO: check for existing maintaiers file |
| 70 | 71 | ||
| 71 | let mut client = Client::default(); | 72 | let mut client = Client::new(Params::with_git_config_relay_defaults(&Some(&git_repo))); |
| 72 | 73 | ||
| 73 | let repo_coordinate = (try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await).ok(); | 74 | let repo_coordinate = (try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await).ok(); |
| 74 | 75 | ||
diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs index e8d2e97..2c91e66 100644 --- a/src/bin/ngit/sub_commands/list.rs +++ b/src/bin/ngit/sub_commands/list.rs | |||
| @@ -2,7 +2,9 @@ use std::{io::Write, ops::Add}; | |||
| 2 | 2 | ||
| 3 | use anyhow::{Context, Result, bail}; | 3 | use anyhow::{Context, Result, bail}; |
| 4 | use ngit::{ | 4 | use ngit::{ |
| 5 | client::{get_all_proposal_patch_events_from_cache, get_proposals_and_revisions_from_cache}, | 5 | client::{ |
| 6 | Params, get_all_proposal_patch_events_from_cache, get_proposals_and_revisions_from_cache, | ||
| 7 | }, | ||
| 6 | git_events::{ | 8 | git_events::{ |
| 7 | get_commit_id_from_patch, get_most_recent_patch_with_ancestors, status_kinds, tag_value, | 9 | get_commit_id_from_patch, get_most_recent_patch_with_ancestors, status_kinds, tag_value, |
| 8 | }, | 10 | }, |
| @@ -31,7 +33,7 @@ pub async fn launch() -> Result<()> { | |||
| 31 | // TODO: check for existing maintaiers file | 33 | // TODO: check for existing maintaiers file |
| 32 | // TODO: check for other claims | 34 | // TODO: check for other claims |
| 33 | 35 | ||
| 34 | let client = Client::default(); | 36 | let client = Client::new(Params::with_git_config_relay_defaults(&Some(&git_repo))); |
| 35 | 37 | ||
| 36 | let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?; | 38 | let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?; |
| 37 | 39 | ||
diff --git a/src/bin/ngit/sub_commands/login.rs b/src/bin/ngit/sub_commands/login.rs index e76a089..ed2414a 100644 --- a/src/bin/ngit/sub_commands/login.rs +++ b/src/bin/ngit/sub_commands/login.rs | |||
| @@ -2,6 +2,7 @@ use anyhow::{Context, Result}; | |||
| 2 | use clap; | 2 | use clap; |
| 3 | use ngit::{ | 3 | use ngit::{ |
| 4 | cli_interactor::{Interactor, InteractorPrompt, PromptChoiceParms}, | 4 | cli_interactor::{Interactor, InteractorPrompt, PromptChoiceParms}, |
| 5 | client::Params, | ||
| 5 | git::{get_git_config_item, remove_git_config_item}, | 6 | git::{get_git_config_item, remove_git_config_item}, |
| 6 | login::{SignerInfoSource, existing::load_existing_login}, | 7 | login::{SignerInfoSource, existing::load_existing_login}, |
| 7 | }; | 8 | }; |
| @@ -25,15 +26,17 @@ pub struct SubCommandArgs { | |||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | 28 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { |
| 29 | let git_repo_result = Repo::discover().context("failed to find a git repository"); | ||
| 30 | let git_repo = { git_repo_result.ok() }; | ||
| 31 | |||
| 28 | let client = if command_args.offline { | 32 | let client = if command_args.offline { |
| 29 | None | 33 | None |
| 30 | } else { | 34 | } else { |
| 31 | Some(Client::default()) | 35 | Some(Client::new(Params::with_git_config_relay_defaults( |
| 36 | &git_repo.as_ref(), | ||
| 37 | ))) | ||
| 32 | }; | 38 | }; |
| 33 | 39 | ||
| 34 | let git_repo_result = Repo::discover().context("failed to find a git repository"); | ||
| 35 | let git_repo = { git_repo_result.ok() }; | ||
| 36 | |||
| 37 | let (logged_out, log_in_locally_only) = logout(git_repo.as_ref(), command_args.local).await?; | 40 | let (logged_out, log_in_locally_only) = logout(git_repo.as_ref(), command_args.local).await?; |
| 38 | if logged_out || log_in_locally_only { | 41 | if logged_out || log_in_locally_only { |
| 39 | fresh_login_or_signup( | 42 | fresh_login_or_signup( |
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index 9fc00d9..5a5acc8 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs | |||
| @@ -2,7 +2,10 @@ use std::path::Path; | |||
| 2 | 2 | ||
| 3 | use anyhow::{Context, Result, bail}; | 3 | use anyhow::{Context, Result, bail}; |
| 4 | use console::Style; | 4 | use console::Style; |
| 5 | use ngit::{client::send_events, git_events::generate_cover_letter_and_patch_events}; | 5 | use ngit::{ |
| 6 | client::{Params, send_events}, | ||
| 7 | git_events::generate_cover_letter_and_patch_events, | ||
| 8 | }; | ||
| 6 | use nostr::{ | 9 | use nostr::{ |
| 7 | ToBech32, | 10 | ToBech32, |
| 8 | nips::{nip10::Marker, nip19::Nip19Event}, | 11 | nips::{nip10::Marker, nip19::Nip19Event}, |
| @@ -52,7 +55,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 52 | .get_main_or_master_branch() | 55 | .get_main_or_master_branch() |
| 53 | .context("the default branches (main or master) do not exist")?; | 56 | .context("the default branches (main or master) do not exist")?; |
| 54 | 57 | ||
| 55 | let mut client = Client::default(); | 58 | let mut client = Client::new(Params::with_git_config_relay_defaults(&Some(&git_repo))); |
| 56 | 59 | ||
| 57 | let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?; | 60 | let repo_coordinates = get_repo_coordinates_when_remote_unknown(&git_repo, &client).await?; |
| 58 | 61 | ||