From 0cad465dd3f78bd6c680067d12d396d4782829bf Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 25 Jul 2025 15:52:19 +0100 Subject: fix(list): improve pr unsupport text and show a more helpful message when proposal can be checked out using the remote --- src/lib/git/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/lib/git') 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::{ Tags, hashes::{Hash, sha1::Hash as Sha1Hash}, }; +use nostr_url::NostrUrlDecoded; use crate::git_events::{get_commit_id_from_patch, tag_value}; pub mod identify_ahead_behind; @@ -92,6 +93,10 @@ pub trait RepoActions { fn get_git_config_item(&self, item: &str, global: Option) -> Result>; fn save_git_config_item(&self, item: &str, value: &str, global: bool) -> Result<()>; fn remove_git_config_item(&self, item: &str, global: bool) -> Result; + #[allow(async_fn_in_trait)] + async fn get_first_nostr_remote_when_in_ngit_binary( + &self, + ) -> Result>; } impl RepoActions for Repo { @@ -796,6 +801,21 @@ impl RepoActions for Repo { Ok(true) } } + + async fn get_first_nostr_remote_when_in_ngit_binary( + &self, + ) -> Result> { + for remote_name in self.git_repo.remotes()?.iter().flatten() { + if let Some(remote_url) = self.git_repo.find_remote(remote_name)?.url() { + if let Ok(nostr_url_decoded) = + NostrUrlDecoded::parse_and_resolve(remote_url, &Some(self)).await + { + return Ok(Some((remote_name.to_string(), nostr_url_decoded))); + } + } + } + Ok(None) + } } fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] { -- cgit v1.2.3