diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-12-09 09:34:08 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-12-10 11:55:01 +0000 |
| commit | 6d3a4eb870cd344b11ccda13e1339584ed4e4d17 (patch) | |
| tree | 37cb5787bb62c519a235d5a8b0c5c0985d8b4977 /src/bin/git_remote_nostr/main.rs | |
| parent | f0d0e1ba1cba11d3a98a5ab0c7f1dc72b6bc4e17 (diff) | |
feat(NostrUrlDecoded) add nip05 support
replace `NostrUrlDecoded::from_str` with
`NostrUrlDecoded::parse_and_resolve`
store nip05 pubkey mapping in git cache
Diffstat (limited to 'src/bin/git_remote_nostr/main.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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::{ | |||
| 9 | collections::HashSet, | 9 | collections::HashSet, |
| 10 | env, io, | 10 | env, io, |
| 11 | path::{Path, PathBuf}, | 11 | path::{Path, PathBuf}, |
| 12 | str::FromStr, | ||
| 13 | }; | 12 | }; |
| 14 | 13 | ||
| 15 | use anyhow::{bail, Context, Result}; | 14 | use anyhow::{bail, Context, Result}; |
| @@ -28,7 +27,7 @@ mod utils; | |||
| 28 | 27 | ||
| 29 | #[tokio::main] | 28 | #[tokio::main] |
| 30 | async fn main() -> Result<()> { | 29 | async fn main() -> Result<()> { |
| 31 | let Some((decoded_nostr_url, git_repo)) = process_args()? else { | 30 | let Some((decoded_nostr_url, git_repo)) = process_args().await? else { |
| 32 | return Ok(()); | 31 | return Ok(()); |
| 33 | }; | 32 | }; |
| 34 | 33 | ||
| @@ -109,7 +108,7 @@ async fn main() -> Result<()> { | |||
| 109 | } | 108 | } |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 112 | fn process_args() -> Result<Option<(NostrUrlDecoded, Repo)>> { | 111 | async fn process_args() -> Result<Option<(NostrUrlDecoded, Repo)>> { |
| 113 | let args = env::args(); | 112 | let args = env::args(); |
| 114 | let args = args.skip(1).take(2).collect::<Vec<_>>(); | 113 | let args = args.skip(1).take(2).collect::<Vec<_>>(); |
| 115 | 114 | ||
| @@ -135,13 +134,14 @@ fn process_args() -> Result<Option<(NostrUrlDecoded, Repo)>> { | |||
| 135 | return Ok(None); | 134 | return Ok(None); |
| 136 | }; | 135 | }; |
| 137 | 136 | ||
| 138 | let decoded_nostr_url = | ||
| 139 | NostrUrlDecoded::from_str(nostr_remote_url).context("invalid nostr url")?; | ||
| 140 | |||
| 141 | let git_repo = Repo::from_path(&PathBuf::from( | 137 | let git_repo = Repo::from_path(&PathBuf::from( |
| 142 | std::env::var("GIT_DIR").context("git should set GIT_DIR when remote helper is called")?, | 138 | std::env::var("GIT_DIR").context("git should set GIT_DIR when remote helper is called")?, |
| 143 | ))?; | 139 | ))?; |
| 144 | 140 | ||
| 141 | let decoded_nostr_url = NostrUrlDecoded::parse_and_resolve(nostr_remote_url, &Some(&git_repo)) | ||
| 142 | .await | ||
| 143 | .context("invalid nostr url")?; | ||
| 144 | |||
| 145 | Ok(Some((decoded_nostr_url, git_repo))) | 145 | Ok(Some((decoded_nostr_url, git_repo))) |
| 146 | } | 146 | } |
| 147 | 147 | ||