add repo detail view

This commit is contained in:
2026-08-10 08:33:19 +07:00
parent e36d96bf50
commit 831a89dd11
12 changed files with 1060 additions and 7 deletions
+44
View File
@@ -0,0 +1,44 @@
use std::path::PathBuf;
use gpui::{App, Global};
use signed_git::GitCache;
struct GlobalGitStore(GitCache);
impl Global for GlobalGitStore {}
/// Global access to the on-disk git clone cache (grasp mirrors).
///
/// Installed at startup via [`GitStore::set_global`]; see also
/// [`signed_state::init`].
#[derive(Debug, Clone)]
pub struct GitStore(GitCache);
impl GitStore {
/// Register the clone cache rooted at `root` as an app-wide global.
/// Replaces any previously installed store (see [`signed_state::init`], which
/// installs an empty one).
pub fn set_global(root: impl Into<PathBuf>, cx: &mut App) -> Self {
let store = Self::new(root);
cx.set_global(GlobalGitStore(store.0.clone()));
store
}
/// The app-wide clone cache.
///
/// # Panics
///
/// Panics if [`GitStore::set_global`] was never called.
pub fn global(cx: &App) -> Self {
Self(cx.global::<GlobalGitStore>().0.clone())
}
fn new(root: impl Into<PathBuf>) -> Self {
Self(GitCache::new(root.into()))
}
/// Underlying clone cache.
pub fn cache(&self) -> &GitCache {
&self.0
}
}
+10 -2
View File
@@ -1,18 +1,20 @@
mod backend;
mod git_store;
mod profile;
mod repo;
mod repo_list;
use std::path::Path;
use std::path::{Path, PathBuf};
pub use backend::{Backend, BackendEvent};
pub use git_store::GitStore;
use gpui::{App, AppContext, Entity};
pub use nostr_sdk::prelude::Timestamp;
pub use profile::{Profile, ProfileStore};
pub use utils::shorten_pubkey;
pub use repo::RepoStore;
pub use repo_list::RepoListStore;
use signed_nostr::new_backend;
pub use utils::shorten_pubkey;
/// Initialize the backend and stores, and install them as globals. Call once
/// at startup, before opening any window that uses the stores.
@@ -35,6 +37,10 @@ pub fn init(db_path: impl AsRef<Path>, cx: &mut App) -> Entity<Backend> {
ProfileStore::set_global(cx.new(ProfileStore::new), cx);
// The clone cache is only meaningful on native platforms; the wasm
// build registers an empty store so `GitStore::global` still works.
GitStore::set_global(PathBuf::new(), cx);
entity
}
@@ -48,5 +54,7 @@ pub fn init(cx: &mut App) -> Entity<Backend> {
ProfileStore::set_global(cx.new(ProfileStore::new), cx);
GitStore::set_global(PathBuf::new(), cx);
entity
}