Skip to content
Clone
198a626
68 lines 1.3 KB Rust
use crate::object::cache::ObjectCache;
use crate::policy::{DefaultPolicy, Policy};
use std::path::PathBuf;
use std::sync::Arc;
pub mod error;
pub use error::Error;
use storage::StorageRepository;
pub mod gitcli;
pub mod policy;
pub mod validate;
pub mod analysis;
pub mod archive;
pub mod blob;
pub mod commit;
pub mod conflict;
pub mod diff;
pub mod gc;
pub mod graphql;
pub mod hook;
pub mod lfs;
pub mod log;
pub mod object;
pub mod pack;
pub mod patch;
pub mod pipeline;
pub mod refs;
pub mod remote;
pub mod signature;
pub mod submodule;
pub mod tag;
pub mod tree;
pub(crate) mod usecase_cache;
#[derive(Clone)]
pub struct GitRepository {
pub path: PathBuf,
pub cache: ObjectCache,
pub policy: Policy,
pub storage: Arc<Box<dyn StorageRepository>>,
}
impl GitRepository {
pub fn repo(&self) -> Result<gix::Repository, crate::Error> {
gix::open(&self.path).map_err(|e| crate::Error::Open(e.to_string()))
}
pub fn new(
path: impl Into<PathBuf>,
cache: ObjectCache,
storage: Arc<Box<dyn StorageRepository>>,
) -> Self {
Self {
path: path.into(),
cache,
policy: Arc::new(DefaultPolicy),
storage,
}
}
pub fn with_policy(mut self, policy: Policy) -> Self {
self.policy = policy;
self
}
}