Do not store reference to store path in the hook objects
This commit is contained in:
parent
6714f4e3c7
commit
112646c002
4 changed files with 30 additions and 30 deletions
|
@ -23,27 +23,27 @@ use vcs::git::error::GitHookErrorKind as GHEK;
|
||||||
use vcs::git::error::GitHookError as GHE;
|
use vcs::git::error::GitHookError as GHE;
|
||||||
use vcs::git::runtime::Runtime;
|
use vcs::git::runtime::Runtime;
|
||||||
|
|
||||||
pub struct CreateHook<'a> {
|
pub struct CreateHook {
|
||||||
storepath: &'a PathBuf,
|
storepath: PathBuf,
|
||||||
|
|
||||||
runtime: Runtime,
|
runtime: Runtime,
|
||||||
|
|
||||||
position: HookPosition,
|
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 {
|
CreateHook {
|
||||||
|
runtime: Runtime::new(&storepath),
|
||||||
storepath: storepath,
|
storepath: storepath,
|
||||||
runtime: Runtime::new(storepath),
|
|
||||||
position: p,
|
position: p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Debug for CreateHook<'a> {
|
impl Debug for CreateHook {
|
||||||
|
|
||||||
fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> {
|
fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> {
|
||||||
write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}",
|
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 {
|
fn name(&self) -> &'static str {
|
||||||
"stdhook_git_create"
|
"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 {
|
fn accessor(&self) -> HookDataAccessor {
|
||||||
HookDataAccessor::StoreIdAccess(self)
|
HookDataAccessor::StoreIdAccess(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StoreIdAccessor for CreateHook<'a> {
|
impl StoreIdAccessor for CreateHook {
|
||||||
|
|
||||||
fn access(&self, id: &StoreId) -> HookResult<()> {
|
fn access(&self, id: &StoreId) -> HookResult<()> {
|
||||||
use vcs::git::action::StoreAction;
|
use vcs::git::action::StoreAction;
|
||||||
|
|
|
@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider};
|
||||||
use libimagstore::hook::accessor::StoreIdAccessor;
|
use libimagstore::hook::accessor::StoreIdAccessor;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DeleteHook<'a> {
|
pub struct DeleteHook {
|
||||||
storepath: &'a PathBuf,
|
storepath: PathBuf,
|
||||||
|
|
||||||
position: HookPosition,
|
position: HookPosition,
|
||||||
config: Option<Value>,
|
config: Option<Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
DeleteHook {
|
||||||
storepath: storepath,
|
storepath: storepath,
|
||||||
position: p,
|
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 {
|
fn name(&self) -> &'static str {
|
||||||
"stdhook_git_delete"
|
"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 {
|
fn accessor(&self) -> HookDataAccessor {
|
||||||
HookDataAccessor::StoreIdAccess(self)
|
HookDataAccessor::StoreIdAccess(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StoreIdAccessor for DeleteHook<'a> {
|
impl StoreIdAccessor for DeleteHook {
|
||||||
|
|
||||||
fn access(&self, id: &StoreId) -> HookResult<()> {
|
fn access(&self, id: &StoreId) -> HookResult<()> {
|
||||||
debug!("[GIT DELETE HOOK]: {:?}", id);
|
debug!("[GIT DELETE HOOK]: {:?}", id);
|
||||||
|
|
|
@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider};
|
||||||
use libimagstore::hook::accessor::StoreIdAccessor;
|
use libimagstore::hook::accessor::StoreIdAccessor;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RetrieveHook<'a> {
|
pub struct RetrieveHook {
|
||||||
storepath: &'a PathBuf,
|
storepath: PathBuf,
|
||||||
|
|
||||||
position: HookPosition,
|
position: HookPosition,
|
||||||
config: Option<Value>,
|
config: Option<Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
RetrieveHook {
|
||||||
storepath: storepath,
|
storepath: storepath,
|
||||||
position: p,
|
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 {
|
fn name(&self) -> &'static str {
|
||||||
"stdhook_git_retrieve"
|
"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 {
|
fn accessor(&self) -> HookDataAccessor {
|
||||||
HookDataAccessor::StoreIdAccess(self)
|
HookDataAccessor::StoreIdAccess(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StoreIdAccessor for RetrieveHook<'a> {
|
impl StoreIdAccessor for RetrieveHook {
|
||||||
|
|
||||||
fn access(&self, id: &StoreId) -> HookResult<()> {
|
fn access(&self, id: &StoreId) -> HookResult<()> {
|
||||||
debug!("[GIT RETRIEVE HOOK]: {:?}", id);
|
debug!("[GIT RETRIEVE HOOK]: {:?}", id);
|
||||||
|
|
|
@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider};
|
||||||
use libimagstore::hook::accessor::StoreIdAccessor;
|
use libimagstore::hook::accessor::StoreIdAccessor;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct UpdateHook<'a> {
|
pub struct UpdateHook {
|
||||||
storepath: &'a PathBuf,
|
storepath: PathBuf,
|
||||||
|
|
||||||
position: HookPosition,
|
position: HookPosition,
|
||||||
config: Option<Value>,
|
config: Option<Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
UpdateHook {
|
||||||
storepath: storepath,
|
storepath: storepath,
|
||||||
position: p,
|
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 {
|
fn name(&self) -> &'static str {
|
||||||
"stdhook_git_update"
|
"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 {
|
fn accessor(&self) -> HookDataAccessor {
|
||||||
HookDataAccessor::StoreIdAccess(self)
|
HookDataAccessor::StoreIdAccess(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StoreIdAccessor for UpdateHook<'a> {
|
impl StoreIdAccessor for UpdateHook {
|
||||||
|
|
||||||
fn access(&self, id: &StoreId) -> HookResult<()> {
|
fn access(&self, id: &StoreId) -> HookResult<()> {
|
||||||
debug!("[GIT UPDATE HOOK]: {:?}", id);
|
debug!("[GIT UPDATE HOOK]: {:?}", id);
|
||||||
|
|
Loading…
Reference in a new issue