Skip to main content

Backend

Trait Backend 

Source
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§

Source

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.

Source

fn pull(&self, directory: &str) -> Result<(), GitError>

Fetches and merges the latest changes from the remote.

Source

fn get_revision(&self, directory: &str) -> Result<String, GitError>

Returns the current git revision (commit SHA).

Source

fn get_status(&self, directory: &str) -> Result<Status, GitError>

Returns the current git status.

Source

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).

Source

fn is_git_repository(&self, directory: &str) -> Result<bool, GitError>

Checks if the directory is a valid git repository.

Source

fn get_current_branch(&self, directory: &str) -> Result<String, GitError>

Returns the current branch name, or empty if detached.

Source

fn is_detached(&self, directory: &str) -> Result<bool, GitError>

Checks if HEAD is detached.

Source

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.

Source

fn get_default_branch( &self, directory: &str, repo_url: &str, ) -> Result<String, GitError>

Detects the default branch from the remote or origin/HEAD.

Source

fn get_commit_counts(&self, directory: &str) -> Result<(i64, i64), GitError>

Returns (behind, ahead) counts vs the tracking branch.

Source

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.

Source

fn merge_ff_only(&self, directory: &str) -> Result<(), GitError>

Fast-forwards the current branch to its upstream; callers must fetch first.

Source

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.

Source

fn checkout(&self, directory: &str, ref_: &str) -> Result<(), GitError>

Checks out the given ref (commit SHA, tag, or branch).

Source

fn stash_push(&self, directory: &str, message: &str) -> Result<(), GitError>

Stashes uncommitted changes with an optional message.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§