upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/git/nostr_url.rs3
-rw-r--r--src/lib/repo_ref.rs16
2 files changed, 9 insertions, 10 deletions
diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs
index de7953f..ae0ac5f 100644
--- a/src/lib/git/nostr_url.rs
+++ b/src/lib/git/nostr_url.rs
@@ -66,6 +66,9 @@ pub struct NostrUrlDecoded {
66 66
67impl fmt::Display for NostrUrlDecoded { 67impl fmt::Display for NostrUrlDecoded {
68 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 68 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
69 if !self.original_string.is_empty() {
70 return write!(f, "{}", self.original_string);
71 }
69 write!(f, "nostr://")?; 72 write!(f, "nostr://")?;
70 if let Some(user) = &self.user { 73 if let Some(user) = &self.user {
71 write!(f, "{}@", user)?; 74 write!(f, "{}@", user)?;
diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs
index 8705597..38f6774 100644
--- a/src/lib/repo_ref.rs
+++ b/src/lib/repo_ref.rs
@@ -241,12 +241,12 @@ impl RepoRef {
241 self.nostr_git_url = Some(nostr_git_url) 241 self.nostr_git_url = Some(nostr_git_url)
242 } 242 }
243 243
244 pub fn to_nostr_git_url(&self, git_repo: &Option<&Repo>) -> String { 244 pub fn to_nostr_git_url(&self, git_repo: &Option<&Repo>) -> NostrUrlDecoded {
245 if let Some(nostr_git_url) = &self.nostr_git_url { 245 if let Some(nostr_git_url) = &self.nostr_git_url {
246 return nostr_git_url.original_string.clone(); 246 return nostr_git_url.clone();
247 } 247 }
248 let c = self.coordinate_with_hint(); 248 let c = self.coordinate_with_hint();
249 format!("{}", NostrUrlDecoded { 249 NostrUrlDecoded {
250 original_string: String::new(), 250 original_string: String::new(),
251 nip05: use_nip05_git_config_cache_to_find_nip05_from_public_key( 251 nip05: use_nip05_git_config_cache_to_find_nip05_from_public_key(
252 &c.public_key, 252 &c.public_key,
@@ -256,7 +256,7 @@ impl RepoRef {
256 coordinate: c, 256 coordinate: c,
257 protocol: None, 257 protocol: None,
258 user: None, 258 user: None,
259 }) 259 }
260 } 260 }
261} 261}
262 262
@@ -460,12 +460,8 @@ fn set_or_create_git_remote_with_nostr_url(
460 repo_ref: &RepoRef, 460 repo_ref: &RepoRef,
461 git_repo: &Repo, 461 git_repo: &Repo,
462) -> Result<()> { 462) -> Result<()> {
463 let url = repo_ref.to_nostr_git_url(&Some(git_repo)); 463 let url = repo_ref.to_nostr_git_url(&Some(git_repo)).to_string();
464 if git_repo 464 if git_repo.git_repo.remote_set_url(name, &url).is_err() {
465 .git_repo
466 .remote_set_url(name, &repo_ref.to_nostr_git_url(&Some(git_repo)))
467 .is_err()
468 {
469 git_repo.git_repo.remote(name, &url)?; 465 git_repo.git_repo.remote(name, &url)?;
470 } 466 }
471 eprintln!("set git remote \"{name}\" to {url}"); 467 eprintln!("set git remote \"{name}\" to {url}");