pub struct GitRepository { /* private fields */ }Expand description
Read-only Repository over an existing git directory.
Implementations§
Trait Implementations§
Source§impl Repository for GitRepository
impl Repository for GitRepository
Source§fn store_blob(&self, _blob: &Blob) -> Result<()>
fn store_blob(&self, _blob: &Blob) -> Result<()>
store_blob is unsupported because Oak’s Blob carries a precomputed BLAKE3
hash, and writing it as a git blob would assign a different OID. Callers must
use Repository::put_blob instead, which returns the canonical git OID.
Source§fn store_manifest(&self, _manifest: &Manifest) -> Result<()>
fn store_manifest(&self, _manifest: &Manifest) -> Result<()>
Unsupported for the same reason as store_blob — Oak’s manifest hash is
BLAKE3 over a flat encoding, but git trees are nested with their own OID
derivation. Callers must use Repository::put_manifest.
Source§fn get_tree(&self, hash: &Hash) -> Result<Option<Tree>>
fn get_tree(&self, hash: &Hash) -> Result<Option<Tree>>
Read the direct children of one git tree as an Oak Tree.
Submodules are skipped (matching read_tree_recursive).
Source§fn store_tree(&self, _tree: &Tree) -> Result<()>
fn store_tree(&self, _tree: &Tree) -> Result<()>
Unsupported for the same reason as store_blob: the Tree’s hash is Oak’s
BLAKE3, but a git tree object would assign its own OID. Use [put_tree]
instead, which returns the git OID.
Source§fn store_branch(&self, branch: &Branch) -> Result<()>
fn store_branch(&self, branch: &Branch) -> Result<()>
Create the git ref for a new branch, pointing at the current HEAD, and
record Oak’s branch metadata (description / parent_branch / status / created_at)
in the sidecar TOML at <git_dir>/oak/branches.toml.
The git ref is what actually makes the branch usable; the sidecar just
preserves Oak-only fields so oak branch show / branch list aren’t lossy.
Source§fn hash_blob_content(&self, content: &[u8]) -> Hash
fn hash_blob_content(&self, content: &[u8]) -> Hash
content via Self::put_blob,
computed without storing anything. Read-only paths (oak status,
restore previews) compare working files against manifest entries
with this; BLAKE3 by default, the git blob OID on the git backend.Source§fn put_blob(&self, content: Vec<u8>) -> Result<Hash>
fn put_blob(&self, content: Vec<u8>) -> Result<Hash>
fn get_blob(&self, hash: &Hash) -> Result<Option<Blob>>
fn has_blob(&self, hash: &Hash) -> Result<bool>
Source§fn put_manifest(&self, entries: Vec<ManifestEntry>) -> Result<Hash>
fn put_manifest(&self, entries: Vec<ManifestEntry>) -> Result<Hash>
fn get_manifest(&self, hash: &Hash) -> Result<Option<Manifest>>
Source§fn put_tree(&self, entries: Vec<ManifestEntry>) -> Result<Hash>
fn put_tree(&self, entries: Vec<ManifestEntry>) -> Result<Hash>
crate::build_tree and the per-tree store_tree.Source§fn walk_tree(&self, root: &Hash) -> Result<Vec<ManifestEntry>>
fn walk_tree(&self, root: &Hash) -> Result<Vec<ManifestEntry>>
root and return its flat entry list.fn get_branch(&self, name: &str) -> Result<Option<Branch>>
fn list_branches(&self) -> Result<Vec<Branch>>
fn update_branch_status(&self, name: &str, status: BranchStatus) -> Result<()>
Source§fn close_branch(
&self,
name: &str,
close_reason: Option<CloseReason>,
) -> Result<()>
fn close_branch( &self, name: &str, close_reason: Option<CloseReason>, ) -> Result<()>
fn update_branch_close_reason( &self, name: &str, close_reason: CloseReason, ) -> Result<()>
fn update_branch_description(&self, name: &str, description: &str) -> Result<()>
fn get_branch_head(&self, name: &str) -> Result<Option<Hash>>
fn set_branch_head(&self, name: &str, hash: &Hash) -> Result<()>
fn store_commit(&self, _commit: &Commit) -> Result<()>
Source§fn put_commit(
&self,
branch_name: String,
parent_hash: Option<Hash>,
merge_parent_hash: Option<Hash>,
manifest_hash: Hash,
author: String,
message: Option<String>,
timestamp: DateTime<Utc>,
files: Vec<FileChange>,
) -> Result<Hash>
fn put_commit( &self, branch_name: String, parent_hash: Option<Hash>, merge_parent_hash: Option<Hash>, manifest_hash: Hash, author: String, message: Option<String>, timestamp: DateTime<Utc>, files: Vec<FileChange>, ) -> Result<Hash>
fn get_commit(&self, hash: &Hash) -> Result<Option<Commit>>
fn has_commit(&self, hash: &Hash) -> Result<bool>
fn get_commits_for_branch(&self, branch_name: &str) -> Result<Vec<Commit>>
fn get_commits_since( &self, branch_name: &str, since: Option<&Hash>, ) -> Result<Vec<Commit>>
fn get_all_commits(&self) -> Result<Vec<Commit>>
fn get_metadata(&self, key: MetadataKey) -> Result<Option<String>>
fn set_metadata(&self, key: MetadataKey, value: &str) -> Result<()>
fn store_chunk(&self, _hash: &Hash, _content: &[u8]) -> Result<()>
fn get_chunk(&self, _hash: &Hash) -> Result<Option<Vec<u8>>>
fn has_chunk(&self, _hash: &Hash) -> Result<bool>
fn store_blob_chunks( &self, _blob_hash: &Hash, _chunks: &[ChunkInfo], ) -> Result<()>
fn get_blob_chunks(&self, _blob_hash: &Hash) -> Result<Option<Vec<ChunkInfo>>>
Source§fn has_blobs(&self, hashes: &[&Hash]) -> Result<Vec<bool>>
fn has_blobs(&self, hashes: &[&Hash]) -> Result<Vec<bool>>
Repository::has_blob for many hashes, in order. Backends override
it to answer a whole manifest’s presence check with one prepared
statement instead of one round trip per entry.fn get_blob_size(&self, hash: &Hash) -> Result<Option<u64>>
fn has_tree(&self, hash: &Hash) -> Result<bool>
Source§fn resolve_path_in_tree(
&self,
root: &Hash,
path: &str,
) -> Result<Option<TreeEntry>>
fn resolve_path_in_tree( &self, root: &Hash, path: &str, ) -> Result<Option<TreeEntry>>
/-separated path to a TreeEntry within the tree at root.Source§fn subtree_at_path(&self, root: &Hash, path: &str) -> Result<Option<Hash>>
fn subtree_at_path(&self, root: &Hash, path: &str) -> Result<Option<Hash>>
path (must be a directory).
An empty path returns Some(root).Source§fn list_branches_isolated(
&self,
) -> Result<Vec<Result<Branch, UnreadableBranch>>>
fn list_branches_isolated( &self, ) -> Result<Vec<Result<Branch, UnreadableBranch>>>
Self::list_branches, but one stored row whose metadata cannot
be decoded becomes an Err(UnreadableBranch) entry instead of failing
the whole listing (fb-118). Batch assessment uses this so a single
corrupt row cannot hide every other branch.Source§fn set_branch_parent(&self, name: &str, parent: Option<&str>) -> Result<()>
fn set_branch_parent(&self, name: &str, parent: Option<&str>) -> Result<()>
store_branch,
which never touches an existing row, this overwrites parent_branch.Source§fn edit_branch_description(&self, name: &str, description: &str) -> Result<()>
fn edit_branch_description(&self, name: &str, description: &str) -> Result<()>
Source§fn description_publication_generation(&self) -> Result<Option<i64>>
fn description_publication_generation(&self) -> Result<Option<i64>>
Source§fn acknowledge_branch_description(
&self,
name: &str,
description: Option<&str>,
generation: Option<i64>,
) -> Result<()>
fn acknowledge_branch_description( &self, name: &str, description: Option<&str>, generation: Option<i64>, ) -> Result<()>
fn rename_branch(&self, old_name: &str, new_name: &str) -> Result<()>
Source§fn delete_branch(&self, name: &str) -> Result<()>
fn delete_branch(&self, name: &str) -> Result<()>
commits.branch_name is a soft
label. Deleting a branch that doesn’t exist is a no-op.Source§fn reconcile_remote_merge_branch_state(
&self,
closed_branch: &str,
new_branch: &Branch,
seed_head: &Hash,
) -> Result<()>
fn reconcile_remote_merge_branch_state( &self, closed_branch: &str, new_branch: &Branch, seed_head: &Hash, ) -> Result<()>
seed_head. Read moreSource§fn repair_commit_fields(&self, verified: &Commit) -> Result<bool>
fn repair_commit_fields(&self, verified: &Commit) -> Result<bool>
verified.hash when its stored
fields don’t reproduce that hash. store_commit keeps the first row it
sees, so a row written with a placeholder author and the client’s
clock (older oak merge binaries did this for the server’s squash
commit) would otherwise never self-verify. Read moreSource§fn merge_child_exists(&self, branch_head: &Hash) -> Result<bool>
fn merge_child_exists(&self, branch_head: &Hash) -> Result<bool>
commits.merge_parent_hash; the default implementation is only for
backends without a native query path.Source§fn count_commits_for_branch(&self, branch_name: &str) -> Result<usize>
fn count_commits_for_branch(&self, branch_name: &str) -> Result<usize>
branch_name — rows whose
branch_name column equals this branch. In Oak’s branch-per-session
model a feature branch is seeded at its parent’s head with none of its
own commits; each oak commit adds one, and a squash-merge moves you
onto a fresh branch with zero again. So this count is exactly the
branch’s local work not yet merged into its parent. Purely local — it
never consults the server. Defaults to counting
Repository::get_commits_for_branch; backends override it with a
cheaper COUNT(*).Source§fn insert_metadata_if_absent(
&self,
key: MetadataKey,
value: &str,
) -> Result<bool>
fn insert_metadata_if_absent( &self, key: MetadataKey, value: &str, ) -> Result<bool>
value only when key has no value yet; returns whether it was
written. Backends that can should make this a single atomic statement
so a concurrent writer’s value is never overwritten.Source§fn load_stat_cache(&self) -> Result<HashMap<String, StatCacheEntry>>
fn load_stat_cache(&self) -> Result<HashMap<String, StatCacheEntry>>
path -> entry map.Source§fn update_stat_cache(
&self,
upserts: &[(String, StatCacheEntry)],
removed: &[String],
) -> Result<()>
fn update_stat_cache( &self, upserts: &[(String, StatCacheEntry)], removed: &[String], ) -> Result<()>
upserts (path + entry) and
delete the paths in removed. Implementations should run this as one
transaction. An empty batch must be a no-op so an unchanged oak status
performs zero writes.Source§fn put_blob_sources(&self, sources: Vec<BlobSource>) -> Result<Vec<Hash>>
fn put_blob_sources(&self, sources: Vec<BlobSource>) -> Result<Vec<Hash>>
read is invoked exactly once, possibly on
a worker thread, to obtain the bytes to store. Semantically identical
to a Repository::put_blob loop (which is the default impl), but it lets
a backend overlap producing one blob’s content (e.g. reading a file)
with hashing/encoding/storing another’s instead of forcing
all-produce-then-all-hash barriers — which is what makes a snapshot of
a few large files fast.Source§fn put_commit_and_advance_refs(
&self,
branch_name: String,
parent_hash: Option<Hash>,
merge_parent_hash: Option<Hash>,
entries: Vec<ManifestEntry>,
author: String,
message: Option<String>,
timestamp: DateTime<Utc>,
files: Vec<FileChange>,
) -> Result<Hash>
fn put_commit_and_advance_refs( &self, branch_name: String, parent_hash: Option<Hash>, merge_parent_hash: Option<Hash>, entries: Vec<ManifestEntry>, author: String, message: Option<String>, timestamp: DateTime<Utc>, files: Vec<FileChange>, ) -> Result<Hash>
Source§fn put_tree_commit_and_advance_refs(
&self,
branch_name: String,
parent_hash: Option<Hash>,
merge_parent_hash: Option<Hash>,
root: Hash,
trees: &[Tree],
author: String,
message: Option<String>,
timestamp: DateTime<Utc>,
files: Vec<FileChange>,
) -> Result<Hash>
fn put_tree_commit_and_advance_refs( &self, branch_name: String, parent_hash: Option<Hash>, merge_parent_hash: Option<Hash>, root: Hash, trees: &[Tree], author: String, message: Option<String>, timestamp: DateTime<Utc>, files: Vec<FileChange>, ) -> Result<Hash>
Self::put_commit_and_advance_refs for a snapshot that already
exists as trees — a tree-level merge’s result — so the whole tree is
never rebuilt from a flat entry list. root is the commit’s root
tree; trees are the ones not stored yet (every other tree under
root must already be). Backends that can publish the whole
transition in one transaction should override this method.fn get_head(&self) -> Result<Option<Hash>>
fn set_head(&self, hash: &Hash) -> Result<()>
fn get_remote_url(&self) -> Result<Option<String>>
fn get_current_branch_name(&self) -> Result<Option<String>>
fn set_current_branch(&self, name: &str) -> Result<()>
Auto Trait Implementations§
impl !Freeze for GitRepository
impl !RefUnwindSafe for GitRepository
impl !UnwindSafe for GitRepository
impl Forget for GitRepository
impl Move for GitRepository
impl Send for GitRepository
impl Sync for GitRepository
impl Unpin for GitRepository
impl UnsafeUnpin for GitRepository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more