use anyhow::Error;
use std::fmt;
use std::path::Path;
#[cfg(not(feature = "git2"))]
#[path = "git/external.rs"]
mod system;
#[cfg(feature = "git2")]
#[path = "git/git2.rs"]
mod system;
pub trait Git: Send + fmt::Debug {
fn path(&self) -> &Path;
fn needs_update(&self) -> Result<bool, Error>;
fn is_fresh(&self) -> Result<bool, Error>;
fn force_update(&self) -> Result<(), Error>;
fn update(&self) -> Result<(), Error>;
}
pub trait GitSystem: Send + Sync {
fn test(&self) -> Result<bool, Error> {
Ok(true)
}
fn clone(&self, url: &str, path: &Path) -> Result<Box<dyn Git>, Error>;
fn open(&self, path: &Path) -> Result<Box<dyn Git>, Error>;
}
pub fn setup() -> Result<Box<dyn GitSystem>, Error> {
Ok(Box::new(system::GitSystem::new()))
}