69f12aa
use std::sync::Arc;
use export::AppState;
use gitbaby::GitBaby;
use sea_orm::DatabaseConnection;
use crate::context::facade::GitContext;
#[derive(Clone)]
pub struct GitService {
pub state: AppState,
}
impl GitService {
pub fn new(state: AppState) -> Self {
// Every host builds a GitService before it can touch a repository, so
// this is the one place that can still shape the environment the `git`
// children will inherit. See `share::git_env` for what it pins and why.
crate::share::git_env::init();
Self { state }
}
pub fn baby(&self, ctx: &GitContext) -> GitBaby {
GitBaby::new(Arc::new(ctx.clone()))
}
pub fn db_write(&self) -> &DatabaseConnection {
self.state.database.write()
}
pub fn db_read(&self) -> &DatabaseConnection {
self.state.database.read()
}
}
pub mod analysis;
pub mod archives;
pub mod blame;
pub mod blobs;
pub mod branches;
pub mod cache;
pub mod clone;
pub mod code_comments;
pub mod commits;
pub mod conflicts;
pub mod content;
pub mod context;
pub mod diffs;
pub mod gitcmd;
pub mod hooks;
pub mod lfs;
pub mod licenses;
pub mod logs;
pub mod maintenance;
pub mod merge;
pub mod packs;
pub mod patches;
pub mod path_log;
pub mod pdf;
pub mod protection;
pub mod refs;
pub mod releases;
pub mod remotes;
pub mod repos;
pub mod signatures;
pub mod stars;
pub mod submodules;
pub mod tags;
pub mod topics;
pub mod trees;
pub mod watches;
pub mod whitelists;