diff options
Diffstat (limited to 'src/bin/git_remote_nostr')
| -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 5f9f712..1a21341 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 | ||
| @@ -118,7 +117,7 @@ async fn main() -> Result<()> { | |||
| 118 | } | 117 | } |
| 119 | } | 118 | } |
| 120 | 119 | ||
| 121 | fn process_args() -> Result<Option<(NostrUrlDecoded, Repo)>> { | 120 | async fn process_args() -> Result<Option<(NostrUrlDecoded, Repo)>> { |
| 122 | let args = env::args(); | 121 | let args = env::args(); |
| 123 | let args = args.skip(1).take(2).collect::<Vec<_>>(); | 122 | let args = args.skip(1).take(2).collect::<Vec<_>>(); |
| 124 | 123 | ||
| @@ -144,13 +143,14 @@ fn process_args() -> Result<Option<(NostrUrlDecoded, Repo)>> { | |||
| 144 | return Ok(None); | 143 | return Ok(None); |
| 145 | }; | 144 | }; |
| 146 | 145 | ||
| 147 | let decoded_nostr_url = | ||
| 148 | NostrUrlDecoded::from_str(nostr_remote_url).context("invalid nostr url")?; | ||
| 149 | |||
| 150 | let git_repo = Repo::from_path(&PathBuf::from( | 146 | let git_repo = Repo::from_path(&PathBuf::from( |
| 151 | std::env::var("GIT_DIR").context("git should set GIT_DIR when remote helper is called")?, | 147 | std::env::var("GIT_DIR").context("git should set GIT_DIR when remote helper is called")?, |
| 152 | ))?; | 148 | ))?; |
| 153 | 149 | ||
| 150 | let decoded_nostr_url = NostrUrlDecoded::parse_and_resolve(nostr_remote_url, &Some(&git_repo)) | ||
| 151 | .await | ||
| 152 | .context("invalid nostr url")?; | ||
| 153 | |||
| 154 | Ok(Some((decoded_nostr_url, git_repo))) | 154 | Ok(Some((decoded_nostr_url, git_repo))) |
| 155 | } | 155 | } |
| 156 | 156 | ||