summaryrefslogtreecommitdiffstats
path: root/libimagrt
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-07-29 10:01:02 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-09-07 22:05:30 +0200
commitf23004a8ec96a1bbcedc7703a3418e39b9970d8c (patch)
tree545348c71e4d6f11b0df5439efe3f76037d7a3fa /libimagrt
parent112646c002882d2d8607f7720593558cabc2fbd4 (diff)
Make git-hook-registration not only when debugging
Diffstat (limited to 'libimagrt')
-rw-r--r--libimagrt/src/runtime.rs25
1 files changed, 20 insertions, 5 deletions
diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs
index df4ba3b9..67d9950b 100644
--- a/libimagrt/src/runtime.rs
+++ b/libimagrt/src/runtime.rs
@@ -123,11 +123,6 @@ impl<'a> Runtime<'a> {
(Box::new(DebugHook::new(HP::PostUpdate)) , "debug", HP::PostUpdate),
(Box::new(DebugHook::new(HP::PreDelete)) , "debug", HP::PreDelete),
(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.
@@ -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 {
cli_matches: matches,
configuration: cfg,