diff options
Diffstat (limited to 'src/lib/repo_ref.rs')
| -rw-r--r-- | src/lib/repo_ref.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs index 089befc..9a3c8f1 100644 --- a/src/lib/repo_ref.rs +++ b/src/lib/repo_ref.rs | |||
| @@ -19,7 +19,10 @@ use crate::{ | |||
| 19 | Interactor, InteractorPrompt, PromptChoiceParms, PromptConfirmParms, PromptInputParms, | 19 | Interactor, InteractorPrompt, PromptChoiceParms, PromptConfirmParms, PromptInputParms, |
| 20 | }, | 20 | }, |
| 21 | client::{consolidate_fetch_reports, get_repo_ref_from_cache, sign_event, Connect}, | 21 | client::{consolidate_fetch_reports, get_repo_ref_from_cache, sign_event, Connect}, |
| 22 | git::{nostr_url::NostrUrlDecoded, Repo, RepoActions}, | 22 | git::{ |
| 23 | nostr_url::{use_nip05_git_config_cache_to_find_nip05_from_public_key, NostrUrlDecoded}, | ||
| 24 | Repo, RepoActions, | ||
| 25 | }, | ||
| 23 | login::user::get_user_details, | 26 | login::user::get_user_details, |
| 24 | }; | 27 | }; |
| 25 | 28 | ||
| @@ -232,15 +235,20 @@ impl RepoRef { | |||
| 232 | .collect::<Vec<(Coordinate, Option<Timestamp>)>>() | 235 | .collect::<Vec<(Coordinate, Option<Timestamp>)>>() |
| 233 | } | 236 | } |
| 234 | 237 | ||
| 235 | pub fn to_nostr_git_url(&self) -> String { | 238 | pub fn to_nostr_git_url(&self, git_repo: &Option<&Repo>) -> String { |
| 239 | let c = self.coordinate_with_hint(); | ||
| 236 | format!( | 240 | format!( |
| 237 | "{}", | 241 | "{}", |
| 238 | NostrUrlDecoded { | 242 | NostrUrlDecoded { |
| 239 | original_string: String::new(), | 243 | original_string: String::new(), |
| 240 | coordinate: self.coordinate_with_hint(), | 244 | nip05: use_nip05_git_config_cache_to_find_nip05_from_public_key( |
| 245 | &c.public_key, | ||
| 246 | git_repo, | ||
| 247 | ) | ||
| 248 | .unwrap_or_default(), | ||
| 249 | coordinate: c, | ||
| 241 | protocol: None, | 250 | protocol: None, |
| 242 | user: None, | 251 | user: None, |
| 243 | nip05: None, // TODO: if nip05 for pubkey saved in local git config use it. | ||
| 244 | } | 252 | } |
| 245 | ) | 253 | ) |
| 246 | } | 254 | } |
| @@ -446,10 +454,10 @@ fn set_or_create_git_remote_with_nostr_url( | |||
| 446 | repo_ref: &RepoRef, | 454 | repo_ref: &RepoRef, |
| 447 | git_repo: &Repo, | 455 | git_repo: &Repo, |
| 448 | ) -> Result<()> { | 456 | ) -> Result<()> { |
| 449 | let url = repo_ref.to_nostr_git_url(); | 457 | let url = repo_ref.to_nostr_git_url(&Some(git_repo)); |
| 450 | if git_repo | 458 | if git_repo |
| 451 | .git_repo | 459 | .git_repo |
| 452 | .remote_set_url(name, &repo_ref.to_nostr_git_url()) | 460 | .remote_set_url(name, &repo_ref.to_nostr_git_url(&Some(git_repo))) |
| 453 | .is_err() | 461 | .is_err() |
| 454 | { | 462 | { |
| 455 | git_repo.git_repo.remote(name, &url)?; | 463 | git_repo.git_repo.remote(name, &url)?; |