diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-05-21 12:32:41 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-05-21 16:21:29 +0100 |
| commit | d64748b810bf64638a5eb71eac054d91dae0c0f1 (patch) | |
| tree | 784412c5f0a7b701cb63d40d2fbaf84694a333d2 /src/bin/ngit/sub_commands/login.rs | |
| parent | 7abd469db87388463187c3a5a9d5b3fe73ffee06 (diff) | |
feat: add support for default relay overrides
via git config so they can be overwritten locally and globally
Diffstat (limited to 'src/bin/ngit/sub_commands/login.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/login.rs | 11 |
1 files changed, 7 insertions, 4 deletions
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( |