diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/git/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index d4bf2f5..b275b49 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs | |||
| @@ -10,6 +10,7 @@ use nostr_sdk::{ | |||
| 10 | Tags, | 10 | Tags, |
| 11 | hashes::{Hash, sha1::Hash as Sha1Hash}, | 11 | hashes::{Hash, sha1::Hash as Sha1Hash}, |
| 12 | }; | 12 | }; |
| 13 | use nostr_url::NostrUrlDecoded; | ||
| 13 | 14 | ||
| 14 | use crate::git_events::{get_commit_id_from_patch, tag_value}; | 15 | use crate::git_events::{get_commit_id_from_patch, tag_value}; |
| 15 | pub mod identify_ahead_behind; | 16 | pub mod identify_ahead_behind; |
| @@ -92,6 +93,10 @@ pub trait RepoActions { | |||
| 92 | fn get_git_config_item(&self, item: &str, global: Option<bool>) -> Result<Option<String>>; | 93 | fn get_git_config_item(&self, item: &str, global: Option<bool>) -> Result<Option<String>>; |
| 93 | fn save_git_config_item(&self, item: &str, value: &str, global: bool) -> Result<()>; | 94 | fn save_git_config_item(&self, item: &str, value: &str, global: bool) -> Result<()>; |
| 94 | fn remove_git_config_item(&self, item: &str, global: bool) -> Result<bool>; | 95 | fn remove_git_config_item(&self, item: &str, global: bool) -> Result<bool>; |
| 96 | #[allow(async_fn_in_trait)] | ||
| 97 | async fn get_first_nostr_remote_when_in_ngit_binary( | ||
| 98 | &self, | ||
| 99 | ) -> Result<Option<(String, NostrUrlDecoded)>>; | ||
| 95 | } | 100 | } |
| 96 | 101 | ||
| 97 | impl RepoActions for Repo { | 102 | impl RepoActions for Repo { |
| @@ -796,6 +801,21 @@ impl RepoActions for Repo { | |||
| 796 | Ok(true) | 801 | Ok(true) |
| 797 | } | 802 | } |
| 798 | } | 803 | } |
| 804 | |||
| 805 | async fn get_first_nostr_remote_when_in_ngit_binary( | ||
| 806 | &self, | ||
| 807 | ) -> Result<Option<(String, NostrUrlDecoded)>> { | ||
| 808 | for remote_name in self.git_repo.remotes()?.iter().flatten() { | ||
| 809 | if let Some(remote_url) = self.git_repo.find_remote(remote_name)?.url() { | ||
| 810 | if let Ok(nostr_url_decoded) = | ||
| 811 | NostrUrlDecoded::parse_and_resolve(remote_url, &Some(self)).await | ||
| 812 | { | ||
| 813 | return Ok(Some((remote_name.to_string(), nostr_url_decoded))); | ||
| 814 | } | ||
| 815 | } | ||
| 816 | } | ||
| 817 | Ok(None) | ||
| 818 | } | ||
| 799 | } | 819 | } |
| 800 | 820 | ||
| 801 | fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] { | 821 | fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] { |