use std::path::Path;
use super::remote::SafePullResult;
use super::status::RepoStatusInfo;
use super::GitError;
pub trait GitBackend: Send + Sync {
fn open_repo(&self, path: &Path) -> Result<Box<dyn GitRepo>, GitError>;
fn clone_repo(
&self,
url: &str,
path: &Path,
branch: Option<&str>,
) -> Result<Box<dyn GitRepo>, GitError>;
fn is_git_repo(&self, path: &Path) -> bool;
}
pub trait GitRepo: Send {
fn workdir(&self) -> &Path;
fn current_branch(&self) -> Result<String, GitError>;
fn head_commit_id(&self) -> Result<String, GitError>;
fn create_and_checkout_branch(&self, name: &str) -> Result<(), GitError>;
fn checkout_branch(&self, name: &str) -> Result<(), GitError>;
fn branch_exists(&self, name: &str) -> bool;
fn remote_branch_exists(&self, name: &str, remote: &str) -> bool;
fn delete_branch(&self, name: &str, force: bool) -> Result<(), GitError>;
fn list_local_branches(&self) -> Result<Vec<String>, GitError>;
fn fetch(&self, remote: &str) -> Result<(), GitError>;
fn pull(&self, remote: &str) -> Result<(), GitError>;
fn push(&self, branch: &str, remote: &str, set_upstream: bool) -> Result<(), GitError>;
fn get_remote_url(&self, remote: &str) -> Result<Option<String>, GitError>;
fn status(&self) -> Result<RepoStatusInfo, GitError>;
fn reset_hard(&self, target: &str) -> Result<(), GitError>;
fn safe_pull(&self, default_branch: &str, remote: &str) -> Result<SafePullResult, GitError>;
}