upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-12-09 09:34:08 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-12-10 11:55:01 +0000
commit6d3a4eb870cd344b11ccda13e1339584ed4e4d17 (patch)
tree37cb5787bb62c519a235d5a8b0c5c0985d8b4977 /src/bin/ngit/sub_commands
parentf0d0e1ba1cba11d3a98a5ab0c7f1dc72b6bc4e17 (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/ngit/sub_commands')
-rw-r--r--src/bin/ngit/sub_commands/init.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 6fc1ec4..c9c8873 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -1,4 +1,4 @@
1use std::{collections::HashMap, str::FromStr}; 1use std::collections::HashMap;
2 2
3use anyhow::{Context, Result}; 3use anyhow::{Context, Result};
4use console::Style; 4use console::Style;
@@ -442,7 +442,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
442 .map(std::string::ToString::to_string) 442 .map(std::string::ToString::to_string)
443 .collect::<Vec<String>>(); 443 .collect::<Vec<String>>();
444 444
445 prompt_to_set_nostr_url_as_origin(&repo_ref, &git_repo)?; 445 prompt_to_set_nostr_url_as_origin(&repo_ref, &git_repo).await?;
446 446
447 // TODO: if no state event exists and there is currently a remote called 447 // TODO: if no state event exists and there is currently a remote called
448 // "origin", automtically push rather than waiting for the next commit 448 // "origin", automtically push rather than waiting for the next commit
@@ -483,7 +483,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
483 Ok(()) 483 Ok(())
484} 484}
485 485
486fn prompt_to_set_nostr_url_as_origin(repo_ref: &RepoRef, git_repo: &Repo) -> Result<()> { 486async fn prompt_to_set_nostr_url_as_origin(repo_ref: &RepoRef, git_repo: &Repo) -> Result<()> {
487 println!( 487 println!(
488 "starting from your next commit, when you `git push` to a remote that uses your nostr url, it will store your repository state on nostr and update the state of the git server(s) you just listed." 488 "starting from your next commit, when you `git push` to a remote that uses your nostr url, it will store your repository state on nostr and update the state of the git server(s) you just listed."
489 ); 489 );
@@ -493,7 +493,9 @@ fn prompt_to_set_nostr_url_as_origin(repo_ref: &RepoRef, git_repo: &Repo) -> Res
493 493
494 if let Ok(origin_remote) = git_repo.git_repo.find_remote("origin") { 494 if let Ok(origin_remote) = git_repo.git_repo.find_remote("origin") {
495 if let Some(origin_url) = origin_remote.url() { 495 if let Some(origin_url) = origin_remote.url() {
496 if let Ok(nostr_url) = NostrUrlDecoded::from_str(origin_url) { 496 if let Ok(nostr_url) =
497 NostrUrlDecoded::parse_and_resolve(origin_url, &Some(git_repo)).await
498 {
497 if nostr_url.coordinate.identifier == repo_ref.identifier { 499 if nostr_url.coordinate.identifier == repo_ref.identifier {
498 if nostr_url.coordinate.public_key == repo_ref.trusted_maintainer { 500 if nostr_url.coordinate.public_key == repo_ref.trusted_maintainer {
499 return Ok(()); 501 return Ok(());