DeleteHook: Use Runtime object internally for storing config

This commit is contained in:
Matthias Beyer 2016-09-17 17:23:23 +02:00
parent db218cb3ee
commit 994d88e65d
1 changed files with 16 additions and 3 deletions

View File

@ -9,21 +9,26 @@ use libimagstore::hook::position::HookPosition;
use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider};
use libimagstore::hook::accessor::StoreIdAccessor;
use vcs::git::error::GitHookErrorKind as GHEK;
use vcs::git::error::MapErrInto;
use vcs::git::runtime::Runtime as GRuntime;
#[derive(Debug)]
pub struct DeleteHook {
storepath: PathBuf,
runtime: GRuntime,
position: HookPosition,
config: Option<Value>,
}
impl DeleteHook {
pub fn new(storepath: PathBuf, p: HookPosition) -> DeleteHook {
DeleteHook {
runtime: GRuntime::new(&storepath),
storepath: storepath,
position: p,
config: None,
}
}
@ -35,8 +40,16 @@ impl Hook for DeleteHook {
"stdhook_git_delete"
}
/// Set the configuration of the hook. See
/// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()`.
///
/// This function traces the error (using `trace_error()`) that
/// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()`
/// returns, if any.
fn set_config(&mut self, config: &Value) {
self.config = Some(config.clone());
if let Err(e) = self.runtime.set_config(config) {
trace_error(&e);
}
}
}