Make git-hook-registration not only when debugging
This commit is contained in:
parent
112646c002
commit
f23004a8ec
1 changed files with 20 additions and 5 deletions
|
@ -123,11 +123,6 @@ impl<'a> Runtime<'a> {
|
||||||
(Box::new(DebugHook::new(HP::PostUpdate)) , "debug", HP::PostUpdate),
|
(Box::new(DebugHook::new(HP::PostUpdate)) , "debug", HP::PostUpdate),
|
||||||
(Box::new(DebugHook::new(HP::PreDelete)) , "debug", HP::PreDelete),
|
(Box::new(DebugHook::new(HP::PreDelete)) , "debug", HP::PreDelete),
|
||||||
(Box::new(DebugHook::new(HP::PostDelete)) , "debug", HP::PostDelete),
|
(Box::new(DebugHook::new(HP::PostDelete)) , "debug", HP::PostDelete),
|
||||||
|
|
||||||
(Box::new(GitCreateHook::new(&storepath, HP::PostCreate)) , "vcs", HP::PostCreate),
|
|
||||||
(Box::new(GitDeleteHook::new(&storepath, HP::PreDelete)) , "vcs", HP::PreDelete),
|
|
||||||
(Box::new(GitRetrieveHook::new(&storepath, HP::PostRetrieve)), "vcs", HP::PostRetrieve),
|
|
||||||
(Box::new(GitUpdateHook::new(&storepath, HP::PostUpdate)) , "vcs", HP::PostUpdate),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// If hook registration fails, trace the error and warn, but continue.
|
// If hook registration fails, trace the error and warn, but continue.
|
||||||
|
@ -143,6 +138,26 @@ impl<'a> Runtime<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sp = storepath;
|
||||||
|
|
||||||
|
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(GitRetrieveHook::new(sp.clone(), HP::PostRetrieve)), "vcs", HP::PostRetrieve),
|
||||||
|
(Box::new(GitUpdateHook::new(sp, HP::PostUpdate)) , "vcs", HP::PostUpdate),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (hook, aspectname, position) in hooks {
|
||||||
|
if let Err(e) = store.register_hook(position, &String::from(aspectname), hook) {
|
||||||
|
if e.err_type() == StoreErrorKind::HookRegisterError {
|
||||||
|
trace_error_dbg(&e);
|
||||||
|
warn!("Registering debug hook with store failed");
|
||||||
|
} else {
|
||||||
|
trace_error(&e);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Runtime {
|
Runtime {
|
||||||
cli_matches: matches,
|
cli_matches: matches,
|
||||||
configuration: cfg,
|
configuration: cfg,
|
||||||
|
|
Loading…
Reference in a new issue