Merge pull request #735 from matthiasbeyer/libimagstorestdhook/git-remove-dead-code
Remove dead code: {Create,Retrieve}Hook implementation
This commit is contained in:
commit
182a3339c7
4 changed files with 0 additions and 150 deletions
|
@ -43,9 +43,7 @@ impl<'a> Runtime<'a> {
|
||||||
use libimagstore::hook::Hook;
|
use libimagstore::hook::Hook;
|
||||||
use libimagstore::error::StoreErrorKind;
|
use libimagstore::error::StoreErrorKind;
|
||||||
use libimagstorestdhook::debug::DebugHook;
|
use libimagstorestdhook::debug::DebugHook;
|
||||||
use libimagstorestdhook::vcs::git::create::CreateHook as GitCreateHook;
|
|
||||||
use libimagstorestdhook::vcs::git::delete::DeleteHook as GitDeleteHook;
|
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 libimagstorestdhook::vcs::git::update::UpdateHook as GitUpdateHook;
|
||||||
use libimagerror::trace::trace_error;
|
use libimagerror::trace::trace_error;
|
||||||
use libimagerror::trace::trace_error_dbg;
|
use libimagerror::trace::trace_error_dbg;
|
||||||
|
@ -141,9 +139,7 @@ impl<'a> Runtime<'a> {
|
||||||
let sp = storepath;
|
let sp = storepath;
|
||||||
|
|
||||||
let hooks : Vec<(Box<Hook>, &str, HP)> = vec![
|
let hooks : Vec<(Box<Hook>, &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(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),
|
(Box::new(GitUpdateHook::new(sp, HP::PostUpdate)) , "vcs", HP::PostUpdate),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -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(())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
mod action;
|
mod action;
|
||||||
mod config;
|
mod config;
|
||||||
pub mod create;
|
|
||||||
pub mod delete;
|
pub mod delete;
|
||||||
mod error;
|
mod error;
|
||||||
mod result;
|
mod result;
|
||||||
mod runtime;
|
mod runtime;
|
||||||
pub mod retrieve;
|
|
||||||
pub mod update;
|
pub mod update;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
|
|
|
@ -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<Value>,
|
|
||||||
}
|
|
||||||
|
|
||||||
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(())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue