zuka
zuka/src/store/mod.rs

worklyn / zukapublic

Agent-first git hosting. One Rust binary: git over HTTP and SSH, a REST API, MCP, CI, and multi-tenant isolation.

Get a copy: git clone https://zuka.worklyn.com/worklyn/zuka.git
zuka/src/store/mod.rs
RSmod.rs1.5 KBDownload
1// Metadata store.
2//
3// Standalone keeps metadata on the same local disk as the repositories, so a
4// self-hoster needs no external service. Control and tenant modes get a remote KV
5// implementation behind this same surface when the control plane lands; nothing
6// above this module knows which is in use.
7
8pub mod cached;
9pub mod fs;
10pub mod quota;
11
12use serde::{Deserialize, Serialize};
13
14/// Where a repository is in its lifecycle.
15///
16/// `Creating` is written *before* `git init` and flipped to `Ready` after. Without
17/// it, a crash between the two leaves a name that is simultaneously 404 (no
18/// metadata) and 409 (directory present) with no way to resolve it.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
20#[serde(rename_all = "lowercase")]
21pub enum RepoState {
22 Creating,
23 Ready,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct RepoRecord {
28 /// Canonical (case-folded) account name. Also the path component.
29 pub account: String,
30 /// Canonical (case-folded) repository name. Also the path component.
31 pub name: String,
32 /// The name as the caller typed it, for display only. Never a path component.
33 pub display_name: String,
34 pub default_branch: String,
35 #[serde(default, skip_serializing_if = "Option::is_none")]
36 pub description: Option<String>,
37 pub created_at: u64,
38 #[serde(default = "ready")]
39 pub state: RepoState,
40}
41
42fn ready() -> RepoState {
43 RepoState::Ready
44}
45
46impl RepoRecord {
47 pub fn is_ready(&self) -> bool {
48 self.state == RepoState::Ready
49 }
50}