This commit is contained in:
2026-09-14 08:50:15 +07:00
parent e556654be8
commit 1a13d4e0d7
8 changed files with 60 additions and 24 deletions
+16 -5
View File
@@ -3,7 +3,8 @@ use std::sync::Arc;
use anyhow::Error;
use gpui::{App, AppContext, Context, Entity, Global, Task};
use signed_git::find_git_repos;
use signed_core::{RepoAddr, repo_addr};
use signed_git::{LocalRepo, find_git_repos};
struct GlobalLocalReposStore(Entity<LocalReposStore>);
@@ -13,7 +14,7 @@ impl Global for GlobalLocalReposStore {}
pub struct LocalReposStore {
pub roots: Arc<Vec<PathBuf>>,
/// Git repositories discovered under [`Self::roots`], sorted by path.
pub repos: Arc<Vec<PathBuf>>,
pub repos: Arc<Vec<LocalRepo>>,
pub scanning: bool,
scan_dirty: bool,
}
@@ -48,7 +49,7 @@ impl LocalReposStore {
self.repos = Arc::new(
self.repos
.iter()
.filter(|repo| repo.as_path() != path)
.filter(|repo| repo.path.as_path() != path)
.cloned()
.collect(),
);
@@ -75,8 +76,8 @@ impl LocalReposStore {
for root in roots.iter() {
repos.extend(find_git_repos(root));
}
repos.sort();
repos.dedup();
repos.sort_by(|a, b| a.path.cmp(&b.path));
repos.dedup_by(|a, b| a.path == b.path);
repos
});
@@ -103,3 +104,13 @@ impl LocalReposStore {
task.detach();
}
}
/// The NIP-34 coordinate a repository's detection resolved, when both the owner
/// and the identifier were recovered.
pub fn local_repo_addr(repo: &LocalRepo) -> Option<RepoAddr> {
let binding = repo.nip34.as_ref()?;
let owner = binding.owner?;
let identifier = binding.identifier.as_deref()?;
Some(repo_addr(owner, identifier))
}