pub struct GitLayer { /* private fields */ }Expand description
Git-based version control layer.
Uses gix for in-process git operations — no subprocess spawning,
no performance overhead of forking git CLI commands.
Implementations§
Source§impl GitLayer
impl GitLayer
Sourcepub fn new(root: PathBuf, enabled: bool) -> Result<Self>
pub fn new(root: PathBuf, enabled: bool) -> Result<Self>
Create a new GitLayer, initializing a repo if needed.
Sourcepub fn commit_file(&self, rel_path: &str, message: &str) -> Result<CommitInfo>
pub fn commit_file(&self, rel_path: &str, message: &str) -> Result<CommitInfo>
Commit a single file with a message (backward-compatible).
Sourcepub fn commit_file_with(
&self,
rel_path: &str,
message: &str,
ctx: CommitContext,
) -> Result<CommitInfo>
pub fn commit_file_with( &self, rel_path: &str, message: &str, ctx: CommitContext, ) -> Result<CommitInfo>
Commit a single file with a message and explicit commit context.
Sourcepub fn commit_files(
&self,
rel_paths: &[&str],
message: &str,
) -> Result<CommitInfo>
pub fn commit_files( &self, rel_paths: &[&str], message: &str, ) -> Result<CommitInfo>
Commit multiple files in a single commit (backward-compatible).
Sourcepub fn commit_files_with(
&self,
rel_paths: &[&str],
message: &str,
ctx: CommitContext,
) -> Result<CommitInfo>
pub fn commit_files_with( &self, rel_paths: &[&str], message: &str, ctx: CommitContext, ) -> Result<CommitInfo>
Commit multiple files with a message and explicit commit context.
Sourcepub fn remove_file(&self, rel_path: &str, message: &str) -> Result<CommitInfo>
pub fn remove_file(&self, rel_path: &str, message: &str) -> Result<CommitInfo>
Remove a file from the repo and commit.
Sourcepub fn log_action(
&self,
agent: &str,
action: &str,
target: &str,
allowed: bool,
detail: Option<&str>,
) -> Result<()>
pub fn log_action( &self, agent: &str, action: &str, target: &str, allowed: bool, detail: Option<&str>, ) -> Result<()>
Append an audit entry to a monthly audit log file and commit it.
Sourcepub fn tag(&self, name: &str, message: &str) -> Result<()>
pub fn tag(&self, name: &str, message: &str) -> Result<()>
Create an annotated tag at the current HEAD.
List all tags in the repository.
Uses Category::Tag to correctly filter only tag refs.
Sourcepub fn log(&self, max_count: usize) -> Result<Vec<LogEntry>>
pub fn log(&self, max_count: usize) -> Result<Vec<LogEntry>>
Return commit log entries, most recent first.
Sourcepub fn resolve_partial_hash(&self, partial: &str) -> Result<ObjectId>
pub fn resolve_partial_hash(&self, partial: &str) -> Result<ObjectId>
Resolve a partial commit hash to full ObjectId.
Sourcepub fn restore_file(&self, rel_path: &str, hash: &str) -> Result<()>
pub fn restore_file(&self, rel_path: &str, hash: &str) -> Result<()>
Restore a file to its state in a specific commit.
Supports nested paths like audit/2024-05.audit by traversing
each path component through sub-trees.
Sourcepub fn diff_commits(&self, from_hash: &str, to_hash: &str) -> Result<CommitDiff>
pub fn diff_commits(&self, from_hash: &str, to_hash: &str) -> Result<CommitDiff>
Compute the diff between two commits.
Sourcepub fn file_at_commit(&self, rel_path: &str, hash: &str) -> Result<Vec<u8>>
pub fn file_at_commit(&self, rel_path: &str, hash: &str) -> Result<Vec<u8>>
Retrieve file content as it was at a specific commit.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether auto-commit is enabled.