From 6d3a4eb870cd344b11ccda13e1339584ed4e4d17 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 9 Dec 2024 09:34:08 +0000 Subject: feat(NostrUrlDecoded) add nip05 support replace `NostrUrlDecoded::from_str` with `NostrUrlDecoded::parse_and_resolve` store nip05 pubkey mapping in git cache --- src/bin/git_remote_nostr/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/bin/git_remote_nostr/main.rs') diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index 8e12d68..84327d7 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs @@ -9,7 +9,6 @@ use std::{ collections::HashSet, env, io, path::{Path, PathBuf}, - str::FromStr, }; use anyhow::{bail, Context, Result}; @@ -28,7 +27,7 @@ mod utils; #[tokio::main] async fn main() -> Result<()> { - let Some((decoded_nostr_url, git_repo)) = process_args()? else { + let Some((decoded_nostr_url, git_repo)) = process_args().await? else { return Ok(()); }; @@ -109,7 +108,7 @@ async fn main() -> Result<()> { } } -fn process_args() -> Result> { +async fn process_args() -> Result> { let args = env::args(); let args = args.skip(1).take(2).collect::>(); @@ -135,13 +134,14 @@ fn process_args() -> Result> { return Ok(None); }; - let decoded_nostr_url = - NostrUrlDecoded::from_str(nostr_remote_url).context("invalid nostr url")?; - let git_repo = Repo::from_path(&PathBuf::from( std::env::var("GIT_DIR").context("git should set GIT_DIR when remote helper is called")?, ))?; + let decoded_nostr_url = NostrUrlDecoded::parse_and_resolve(nostr_remote_url, &Some(&git_repo)) + .await + .context("invalid nostr url")?; + Ok(Some((decoded_nostr_url, git_repo))) } -- cgit v1.2.3