upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/repo_ref.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/repo_ref.rs b/src/repo_ref.rs
index fa8ff4e..94af864 100644
--- a/src/repo_ref.rs
+++ b/src/repo_ref.rs
@@ -16,7 +16,7 @@ use crate::client::Client;
16use crate::{ 16use crate::{
17 cli_interactor::{Interactor, InteractorPrompt, PromptInputParms}, 17 cli_interactor::{Interactor, InteractorPrompt, PromptInputParms},
18 client::{get_event_from_global_cache, get_events_from_cache, sign_event, Connect}, 18 client::{get_event_from_global_cache, get_events_from_cache, sign_event, Connect},
19 git::{Repo, RepoActions}, 19 git::{nostr_git_url_to_repo_coordinates, Repo, RepoActions},
20}; 20};
21 21
22#[derive(Default)] 22#[derive(Default)]
@@ -229,8 +229,9 @@ pub async fn try_and_get_repo_coordinates(
229) -> Result<HashSet<Coordinate>> { 229) -> Result<HashSet<Coordinate>> {
230 let mut repo_coordinates = get_repo_coordinates_from_git_config(git_repo)?; 230 let mut repo_coordinates = get_repo_coordinates_from_git_config(git_repo)?;
231 231
232 // TODO: when nostr remotes functionality is added, iterate on each remote and 232 if repo_coordinates.is_empty() {
233 // extract coordinates 233 repo_coordinates = get_repo_coordinates_from_nostr_remotes(git_repo)?;
234 }
234 235
235 if repo_coordinates.is_empty() { 236 if repo_coordinates.is_empty() {
236 repo_coordinates = get_repo_coordinates_from_maintainers_yaml(git_repo, client).await?; 237 repo_coordinates = get_repo_coordinates_from_maintainers_yaml(git_repo, client).await?;
@@ -258,6 +259,20 @@ fn get_repo_coordinates_from_git_config(git_repo: &Repo) -> Result<HashSet<Coord
258 Ok(repo_coordinates) 259 Ok(repo_coordinates)
259} 260}
260 261
262fn get_repo_coordinates_from_nostr_remotes(git_repo: &Repo) -> Result<HashSet<Coordinate>> {
263 let mut repo_coordinates = HashSet::new();
264 for remote_name in git_repo.git_repo.remotes()?.iter().flatten() {
265 if let Some(remote_url) = git_repo.git_repo.find_remote(remote_name)?.url() {
266 if let Ok(coordinates) = nostr_git_url_to_repo_coordinates(remote_url) {
267 for c in coordinates {
268 repo_coordinates.insert(c);
269 }
270 }
271 }
272 }
273 Ok(repo_coordinates)
274}
275
261async fn get_repo_coordinates_from_maintainers_yaml( 276async fn get_repo_coordinates_from_maintainers_yaml(
262 git_repo: &Repo, 277 git_repo: &Repo,
263 #[cfg(test)] client: &crate::client::MockConnect, 278 #[cfg(test)] client: &crate::client::MockConnect,