From 112646c002882d2d8607f7720593558cabc2fbd4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 10:00:28 +0200 Subject: [PATCH] Do not store reference to store path in the hook objects --- libimagstorestdhook/src/vcs/git/create.rs | 18 +++++++++--------- libimagstorestdhook/src/vcs/git/delete.rs | 14 +++++++------- libimagstorestdhook/src/vcs/git/retrieve.rs | 14 +++++++------- libimagstorestdhook/src/vcs/git/update.rs | 14 +++++++------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 7fb39739..43fd1c7a 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -23,27 +23,27 @@ use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::GitHookError as GHE; use vcs::git::runtime::Runtime; -pub struct CreateHook<'a> { - storepath: &'a PathBuf, +pub struct CreateHook { + storepath: PathBuf, runtime: Runtime, position: HookPosition, } -impl<'a> CreateHook<'a> { +impl CreateHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> CreateHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> CreateHook { CreateHook { + runtime: Runtime::new(&storepath), storepath: storepath, - runtime: Runtime::new(storepath), position: p, } } } -impl<'a> Debug for CreateHook<'a> { +impl Debug for CreateHook { fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", @@ -54,7 +54,7 @@ impl<'a> Debug for CreateHook<'a> { } } -impl<'a> Hook for CreateHook<'a> { +impl Hook for CreateHook { fn name(&self) -> &'static str { "stdhook_git_create" @@ -68,14 +68,14 @@ impl<'a> Hook for CreateHook<'a> { } -impl<'a> HookDataAccessorProvider for CreateHook<'a> { +impl HookDataAccessorProvider for CreateHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for CreateHook<'a> { +impl StoreIdAccessor for CreateHook { fn access(&self, id: &StoreId) -> HookResult<()> { use vcs::git::action::StoreAction; diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index fd476b21..902e5096 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct DeleteHook<'a> { - storepath: &'a PathBuf, +pub struct DeleteHook { + storepath: PathBuf, position: HookPosition, config: Option, } -impl<'a> DeleteHook<'a> { +impl DeleteHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> DeleteHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> DeleteHook { DeleteHook { storepath: storepath, position: p, @@ -29,7 +29,7 @@ impl<'a> DeleteHook<'a> { } -impl<'a> Hook for DeleteHook<'a> { +impl Hook for DeleteHook { fn name(&self) -> &'static str { "stdhook_git_delete" @@ -41,14 +41,14 @@ impl<'a> Hook for DeleteHook<'a> { } -impl<'a> HookDataAccessorProvider for DeleteHook<'a> { +impl HookDataAccessorProvider for DeleteHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for DeleteHook<'a> { +impl StoreIdAccessor for DeleteHook { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT DELETE HOOK]: {:?}", id); diff --git a/libimagstorestdhook/src/vcs/git/retrieve.rs b/libimagstorestdhook/src/vcs/git/retrieve.rs index ae7b61e6..ca034812 100644 --- a/libimagstorestdhook/src/vcs/git/retrieve.rs +++ b/libimagstorestdhook/src/vcs/git/retrieve.rs @@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct RetrieveHook<'a> { - storepath: &'a PathBuf, +pub struct RetrieveHook { + storepath: PathBuf, position: HookPosition, config: Option, } -impl<'a> RetrieveHook<'a> { +impl RetrieveHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> RetrieveHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> RetrieveHook { RetrieveHook { storepath: storepath, position: p, @@ -29,7 +29,7 @@ impl<'a> RetrieveHook<'a> { } -impl<'a> Hook for RetrieveHook<'a> { +impl Hook for RetrieveHook { fn name(&self) -> &'static str { "stdhook_git_retrieve" @@ -41,14 +41,14 @@ impl<'a> Hook for RetrieveHook<'a> { } -impl<'a> HookDataAccessorProvider for RetrieveHook<'a> { +impl HookDataAccessorProvider for RetrieveHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for RetrieveHook<'a> { +impl StoreIdAccessor for RetrieveHook { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT RETRIEVE HOOK]: {:?}", id); diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index f551d7f6..4a5026d0 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct UpdateHook<'a> { - storepath: &'a PathBuf, +pub struct UpdateHook { + storepath: PathBuf, position: HookPosition, config: Option, } -impl<'a> UpdateHook<'a> { +impl UpdateHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> UpdateHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> UpdateHook { UpdateHook { storepath: storepath, position: p, @@ -29,7 +29,7 @@ impl<'a> UpdateHook<'a> { } -impl<'a> Hook for UpdateHook<'a> { +impl Hook for UpdateHook { fn name(&self) -> &'static str { "stdhook_git_update" @@ -41,14 +41,14 @@ impl<'a> Hook for UpdateHook<'a> { } -impl<'a> HookDataAccessorProvider for UpdateHook<'a> { +impl HookDataAccessorProvider for UpdateHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for UpdateHook<'a> { +impl StoreIdAccessor for UpdateHook { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT UPDATE HOOK]: {:?}", id);