Skip to main content

VcsBackend

Trait VcsBackend 

Source
pub trait VcsBackend: Send + Sync {
Show 18 methods // Required methods fn init(&self, path: &Path) -> Result<(), NapError>; fn commit( &self, path: &Path, message: &str, author: &str, ) -> Result<String, NapError>; fn read_file_at_ref( &self, repo_path: &Path, file_path: &str, reference: Option<&str>, ) -> Result<String, NapError>; fn log( &self, path: &Path, file: Option<&str>, limit: usize, ) -> Result<Vec<CommitInfo>, NapError>; fn create_branch(&self, path: &Path, name: &str) -> Result<(), NapError>; fn switch_branch(&self, path: &Path, name: &str) -> Result<(), NapError>; fn create_tag(&self, path: &Path, name: &str) -> Result<(), NapError>; fn current_branch(&self, path: &Path) -> Result<String, NapError>; fn head_hash(&self, path: &Path) -> Result<String, NapError>; fn list_branches(&self, path: &Path) -> Result<Vec<String>, NapError>; fn list_tags(&self, path: &Path) -> Result<Vec<String>, NapError>; fn add_remote( &self, path: &Path, name: &str, url: &str, ) -> Result<(), NapError>; fn remove_remote(&self, path: &Path, name: &str) -> Result<(), NapError>; fn list_remotes( &self, path: &Path, ) -> Result<Vec<(String, String)>, NapError>; fn push( &self, path: &Path, remote: Option<&str>, branch: Option<&str>, ) -> Result<(), NapError>; fn pull( &self, path: &Path, remote: Option<&str>, branch: Option<&str>, ) -> Result<(), NapError>; // Provided methods fn revert( &self, _path: &Path, _commit_hash: &str, ) -> Result<String, NapError> { ... } fn resolve_branch_head( &self, path: &Path, branch: &str, ) -> Result<String, NapError> { ... }
}
Expand description

Low-level abstraction over a version control system.

Implementors: GitBackend (deprecated), LoreBackend (production).

Most consumer code should use [RepoService] instead — it adds permissions, context-document management, autopublish, and a workspace-lifecycle API on top of this trait.

Required Methods§

Source

fn init(&self, path: &Path) -> Result<(), NapError>

Initialize a new repository at the given path.

Source

fn commit( &self, path: &Path, message: &str, author: &str, ) -> Result<String, NapError>

Stage all files and create a commit.

Source

fn read_file_at_ref( &self, repo_path: &Path, file_path: &str, reference: Option<&str>, ) -> Result<String, NapError>

Read a file’s content at a specific ref (branch, tag, or commit hash). If reference is None, reads from the current working tree.

Source

fn log( &self, path: &Path, file: Option<&str>, limit: usize, ) -> Result<Vec<CommitInfo>, NapError>

Get the commit log for the repository, optionally filtered to a specific file.

Source

fn create_branch(&self, path: &Path, name: &str) -> Result<(), NapError>

Create a new branch.

Source

fn switch_branch(&self, path: &Path, name: &str) -> Result<(), NapError>

Switch to a branch.

Source

fn create_tag(&self, path: &Path, name: &str) -> Result<(), NapError>

Create a tag at the current HEAD.

Source

fn current_branch(&self, path: &Path) -> Result<String, NapError>

Get the current branch name.

Source

fn head_hash(&self, path: &Path) -> Result<String, NapError>

Get the HEAD commit hash.

Source

fn list_branches(&self, path: &Path) -> Result<Vec<String>, NapError>

List all branches.

Source

fn list_tags(&self, path: &Path) -> Result<Vec<String>, NapError>

List all tags.

Source

fn add_remote(&self, path: &Path, name: &str, url: &str) -> Result<(), NapError>

Add a remote.

Source

fn remove_remote(&self, path: &Path, name: &str) -> Result<(), NapError>

Remove a remote.

Source

fn list_remotes(&self, path: &Path) -> Result<Vec<(String, String)>, NapError>

List remotes as (name, url) pairs.

Source

fn push( &self, path: &Path, remote: Option<&str>, branch: Option<&str>, ) -> Result<(), NapError>

Push the current branch to its upstream / a named remote.

Source

fn pull( &self, path: &Path, remote: Option<&str>, branch: Option<&str>, ) -> Result<(), NapError>

Pull the current branch from its upstream / a named remote.

Provided Methods§

Source

fn revert(&self, _path: &Path, _commit_hash: &str) -> Result<String, NapError>

Revert a commit by creating a new commit that undoes it.

Source

fn resolve_branch_head( &self, path: &Path, branch: &str, ) -> Result<String, NapError>

Resolve the most recent commit hash on a given branch.

The default implementation returns an error — backends that support branch-based resolution must override this.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§