From 6ecd97956f435a152300b334615396a7d4694f62 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 22:42:10 +0200 Subject: [PATCH] Add boilerplate for update hook --- libimagstorestdhook/src/vcs/git/update.rs | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index e69de29b..67bb85d4 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -0,0 +1,54 @@ +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 UpdateHook { + position: HookPosition, + config: Option, +} + +impl UpdateHook { + + pub fn new(p: HookPosition) -> UpdateHook { + UpdateHook { + position: p, + config: None, + } + } + +} + +impl Hook for UpdateHook { + + fn name(&self) -> &'static str { + "stdhook_git_update" + } + + fn set_config(&mut self, config: &Value) { + self.config = Some(config.clone()); + } + +} + +impl HookDataAccessorProvider for UpdateHook { + + fn accessor(&self) -> HookDataAccessor { + HookDataAccessor::StoreIdAccess(self) + } +} + +impl StoreIdAccessor for UpdateHook { + + fn access(&self, id: &StoreId) -> HookResult<()> { + debug!("[GIT UPDATE HOOK]: {:?}", id); + Ok(()) + } + +} +