upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib/git
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-07-25 15:52:19 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-07-25 16:11:01 +0100
commit0cad465dd3f78bd6c680067d12d396d4782829bf (patch)
tree521dbec8d259f7c982345b40bb128a21795a2012 /src/lib/git
parent27cdea120e195b68d998764519ff3a472641c79b (diff)
fix(list): improve pr unsupport text
and show a more helpful message when proposal can be checked out using the remote
Diffstat (limited to 'src/lib/git')
-rw-r--r--src/lib/git/mod.rs20
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};
13use nostr_url::NostrUrlDecoded;
13 14
14use crate::git_events::{get_commit_id_from_patch, tag_value}; 15use crate::git_events::{get_commit_id_from_patch, tag_value};
15pub mod identify_ahead_behind; 16pub 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
97impl RepoActions for Repo { 102impl 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
801fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] { 821fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] {