pub trait Backend {
Show 16 methods
// Required methods
fn clone(&self, repo_url: &str, directory: &str) -> Result<(), GitError>;
fn pull(&self, directory: &str) -> Result<(), GitError>;
fn get_revision(&self, directory: &str) -> Result<String, GitError>;
fn get_status(&self, directory: &str) -> Result<Status, GitError>;
fn ensure_cloned(
&self,
repo_url: &str,
directory: &str,
clone_strategy: &str,
) -> Result<(), GitError>;
fn is_git_repository(&self, directory: &str) -> Result<bool, GitError>;
fn get_current_branch(&self, directory: &str) -> Result<String, GitError>;
fn is_detached(&self, directory: &str) -> Result<bool, GitError>;
fn get_tracking_branch(&self, directory: &str) -> Result<String, GitError>;
fn get_default_branch(
&self,
directory: &str,
repo_url: &str,
) -> Result<String, GitError>;
fn get_commit_counts(&self, directory: &str) -> Result<(i64, i64), GitError>;
fn detect_state(
&self,
directory: &str,
configured_url: &str,
) -> Result<RepositoryState, GitError>;
fn merge_ff_only(&self, directory: &str) -> Result<(), GitError>;
fn fetch(
&self,
directory: &str,
remote: &str,
ref_: &str,
) -> Result<(), GitError>;
fn checkout(&self, directory: &str, ref_: &str) -> Result<(), GitError>;
fn stash_push(&self, directory: &str, message: &str) -> Result<(), GitError>;
}Expand description
Ported from the Backend interface in interface.go.
Required Methods§
Sourcefn clone(&self, repo_url: &str, directory: &str) -> Result<(), GitError>
fn clone(&self, repo_url: &str, directory: &str) -> Result<(), GitError>
Clones the repository to directory. If the directory already
exists and contains a valid clone, this is a no-op.
Sourcefn pull(&self, directory: &str) -> Result<(), GitError>
fn pull(&self, directory: &str) -> Result<(), GitError>
Fetches and merges the latest changes from the remote.
Sourcefn get_revision(&self, directory: &str) -> Result<String, GitError>
fn get_revision(&self, directory: &str) -> Result<String, GitError>
Returns the current git revision (commit SHA).
Sourcefn get_status(&self, directory: &str) -> Result<Status, GitError>
fn get_status(&self, directory: &str) -> Result<Status, GitError>
Returns the current git status.
Sourcefn ensure_cloned(
&self,
repo_url: &str,
directory: &str,
clone_strategy: &str,
) -> Result<(), GitError>
fn ensure_cloned( &self, repo_url: &str, directory: &str, clone_strategy: &str, ) -> Result<(), GitError>
Ensures the repository is cloned based on the clone strategy
("always" or "on-demand"/empty).
Sourcefn is_git_repository(&self, directory: &str) -> Result<bool, GitError>
fn is_git_repository(&self, directory: &str) -> Result<bool, GitError>
Checks if the directory is a valid git repository.
Sourcefn get_current_branch(&self, directory: &str) -> Result<String, GitError>
fn get_current_branch(&self, directory: &str) -> Result<String, GitError>
Returns the current branch name, or empty if detached.
Sourcefn get_tracking_branch(&self, directory: &str) -> Result<String, GitError>
fn get_tracking_branch(&self, directory: &str) -> Result<String, GitError>
Returns the upstream tracking branch (e.g. “origin/main”), or empty if none is set.
Sourcefn get_default_branch(
&self,
directory: &str,
repo_url: &str,
) -> Result<String, GitError>
fn get_default_branch( &self, directory: &str, repo_url: &str, ) -> Result<String, GitError>
Detects the default branch from the remote or origin/HEAD.
Sourcefn get_commit_counts(&self, directory: &str) -> Result<(i64, i64), GitError>
fn get_commit_counts(&self, directory: &str) -> Result<(i64, i64), GitError>
Returns (behind, ahead) counts vs the tracking branch.
Sourcefn detect_state(
&self,
directory: &str,
configured_url: &str,
) -> Result<RepositoryState, GitError>
fn detect_state( &self, directory: &str, configured_url: &str, ) -> Result<RepositoryState, GitError>
Detects the complete state of a repository. Fail-safe: continues collecting state even if some checks fail.
Sourcefn merge_ff_only(&self, directory: &str) -> Result<(), GitError>
fn merge_ff_only(&self, directory: &str) -> Result<(), GitError>
Fast-forwards the current branch to its upstream; callers must fetch first.
Sourcefn fetch(
&self,
directory: &str,
remote: &str,
ref_: &str,
) -> Result<(), GitError>
fn fetch( &self, directory: &str, remote: &str, ref_: &str, ) -> Result<(), GitError>
Fetches a single ref from the given remote without merging; an empty ref fetches all branches.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".