diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index 67d9950b..a942b261 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -43,9 +43,7 @@ impl<'a> Runtime<'a> { use libimagstore::hook::Hook; use libimagstore::error::StoreErrorKind; use libimagstorestdhook::debug::DebugHook; - use libimagstorestdhook::vcs::git::create::CreateHook as GitCreateHook; use libimagstorestdhook::vcs::git::delete::DeleteHook as GitDeleteHook; - use libimagstorestdhook::vcs::git::retrieve::RetrieveHook as GitRetrieveHook; use libimagstorestdhook::vcs::git::update::UpdateHook as GitUpdateHook; use libimagerror::trace::trace_error; use libimagerror::trace::trace_error_dbg; @@ -141,9 +139,7 @@ impl<'a> Runtime<'a> { let sp = storepath; let hooks : Vec<(Box, &str, HP)> = vec![ - (Box::new(GitCreateHook::new(sp.clone(), HP::PostCreate)) , "vcs", HP::PostCreate), (Box::new(GitDeleteHook::new(sp.clone(), HP::PreDelete)) , "vcs", HP::PreDelete), - (Box::new(GitRetrieveHook::new(sp.clone(), HP::PostRetrieve)), "vcs", HP::PostRetrieve), (Box::new(GitUpdateHook::new(sp, HP::PostUpdate)) , "vcs", HP::PostUpdate), ]; diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs deleted file mode 100644 index 431fbd36..00000000 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ /dev/null @@ -1,85 +0,0 @@ -use std::path::PathBuf; -use std::fmt::{Debug, Formatter, Error as FmtError}; -use std::result::Result as RResult; - -use toml::Value; - -use libimagstore::storeid::StoreId; -use libimagstore::hook::Hook; -use libimagstore::hook::result::HookResult; -use libimagstore::hook::position::HookPosition; -use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; -use libimagstore::hook::accessor::StoreIdAccessor; -use libimagerror::trace::trace_error; - -use vcs::git::runtime::Runtime as GRuntime; - -pub struct CreateHook { - storepath: PathBuf, - - runtime: GRuntime, - - position: HookPosition, -} - -impl CreateHook { - - pub fn new(storepath: PathBuf, p: HookPosition) -> CreateHook { - CreateHook { - runtime: GRuntime::new(&storepath), - storepath: storepath, - position: p, - } - } - -} - -impl Debug for CreateHook { - - fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { - write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", - self.storepath, - (if self.runtime.has_repository() { "Some(_)" } else { "None" }), - self.position, - self.runtime.has_config()) - } -} - -impl Hook for CreateHook { - - fn name(&self) -> &'static str { - "stdhook_git_create" - } - - fn set_config(&mut self, config: &Value) { - if let Err(e) = self.runtime.set_config(config) { - trace_error(&e); - } - } - -} - -impl HookDataAccessorProvider for CreateHook { - - fn accessor(&self) -> HookDataAccessor { - HookDataAccessor::StoreIdAccess(self) - } -} - -impl StoreIdAccessor for CreateHook { - - /// The implementation of the CreateHook - /// - /// # Scope - /// - /// What this function has to do is _adding_ the new entry to the git index. - /// After that, the UpdateHook will take care of committing the changes or new file. - /// - fn access(&self, id: &StoreId) -> HookResult<()> { - debug!("[GIT CREATE HOOK]: {:?}", id); - debug!("[GIT CREATE HOOK]: Doing nothing as Store::create() is lazy and does not write to disk"); - Ok(()) - } - -} - diff --git a/libimagstorestdhook/src/vcs/git/mod.rs b/libimagstorestdhook/src/vcs/git/mod.rs index ca9f5c61..e679e6df 100644 --- a/libimagstorestdhook/src/vcs/git/mod.rs +++ b/libimagstorestdhook/src/vcs/git/mod.rs @@ -1,11 +1,9 @@ mod action; mod config; -pub mod create; pub mod delete; mod error; mod result; mod runtime; -pub mod retrieve; pub mod update; pub mod util; diff --git a/libimagstorestdhook/src/vcs/git/retrieve.rs b/libimagstorestdhook/src/vcs/git/retrieve.rs deleted file mode 100644 index ca034812..00000000 --- a/libimagstorestdhook/src/vcs/git/retrieve.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::path::PathBuf; - -use toml::Value; - -use libimagstore::storeid::StoreId; -use libimagstore::hook::Hook; -use libimagstore::hook::result::HookResult; -use libimagstore::hook::position::HookPosition; -use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; -use libimagstore::hook::accessor::StoreIdAccessor; - -#[derive(Debug)] -pub struct RetrieveHook { - storepath: PathBuf, - - position: HookPosition, - config: Option, -} - -impl RetrieveHook { - - pub fn new(storepath: PathBuf, p: HookPosition) -> RetrieveHook { - RetrieveHook { - storepath: storepath, - position: p, - config: None, - } - } - -} - -impl Hook for RetrieveHook { - - fn name(&self) -> &'static str { - "stdhook_git_retrieve" - } - - fn set_config(&mut self, config: &Value) { - self.config = Some(config.clone()); - } - -} - -impl HookDataAccessorProvider for RetrieveHook { - - fn accessor(&self) -> HookDataAccessor { - HookDataAccessor::StoreIdAccess(self) - } -} - -impl StoreIdAccessor for RetrieveHook { - - fn access(&self, id: &StoreId) -> HookResult<()> { - debug!("[GIT RETRIEVE HOOK]: {:?}", id); - Ok(()) - } - -} -