From 173ab188b326fbe78cfba4ab455a74619f4556bb Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 24 Jun 2024 09:39:18 +0100 Subject: feat(login): store in git config and use cache replace ngit yaml file config with: * nsec / ncryptsec / npub in git config in nostr.* namespace * sql database cache for metadata and relay events allow different logins to be used for different git repositories by storing login in local git config --- src/sub_commands/login.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/sub_commands/login.rs') diff --git a/src/sub_commands/login.rs b/src/sub_commands/login.rs index 43ce480..e71d431 100644 --- a/src/sub_commands/login.rs +++ b/src/sub_commands/login.rs @@ -1,11 +1,11 @@ -use anyhow::Result; +use anyhow::{Context, Result}; use clap; #[cfg(not(test))] use crate::client::Client; #[cfg(test)] use crate::client::MockConnect; -use crate::{client::Connect, login, Cli}; +use crate::{client::Connect, git::Repo, login, Cli}; #[derive(clap::Args)] pub struct SubCommandArgs { @@ -15,8 +15,9 @@ pub struct SubCommandArgs { } pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { + let git_repo = Repo::discover().context("cannot find a git repository")?; if command_args.offline { - login::launch(&args.nsec, &args.password, None).await?; + login::launch(&git_repo, &args.nsec, &args.password, None, true).await?; Ok(()) } else { #[cfg(not(test))] @@ -24,7 +25,7 @@ pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { #[cfg(test)] let client = ::default(); - login::launch(&args.nsec, &args.password, Some(&client)).await?; + login::launch(&git_repo, &args.nsec, &args.password, Some(&client), true).await?; client.disconnect().await?; Ok(()) } -- cgit v1.2.3