Rewrite fetch_repo() so we have less overhead in calling this helper

This commit is contained in:
Matthias Beyer 2016-09-07 21:37:56 +02:00
parent ca47744108
commit 032110e6d8
3 changed files with 9 additions and 11 deletions

View file

@ -113,11 +113,9 @@ impl StoreIdAccessor for CreateHook {
try!(self.runtime.ensure_cfg_branch_is_checked_out()); try!(self.runtime.ensure_cfg_branch_is_checked_out());
debug!("[GIT CREATE HOOK]: Branch checked out"); debug!("[GIT CREATE HOOK]: Branch checked out");
let repo = try!(fetch_repo(&self.runtime, let action = StoreAction::Create;
"[GIT CREATE HOOK]: Getting repository",
"[GIT CREATE HOOK]: Couldn't fetch Repository", let repo = try!(fetch_repo(&self.runtime, &action));
"[GIT CREATE HOOK]: Repository object fetched")
);
let mut index = try!( let mut index = try!(
repo repo

View file

@ -97,11 +97,9 @@ impl StoreIdAccessor for UpdateHook {
.map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config") .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config")
); );
let repo = try!(fetch_repo(&self.runtime, let action = StoreAction::Update;
"[GIT UPDATE HOOK]: Getting repository",
"[GIT UPDATE HOOK]: Couldn't fetch Repository", let repo = try!(fetch_repo(&self.runtime, &action));
"[GIT UPDATE HOOK]: Repository object fetched")
);
let mut index = try!( let mut index = try!(
repo repo

View file

@ -15,9 +15,11 @@ use libimagstore::hook::error::HookError;
pub fn fetch_repo<'a>(runtime: &'a GRuntime, action: &StoreAction) -> Result<&'a Repository, HookError> pub fn fetch_repo<'a>(runtime: &'a GRuntime, action: &StoreAction) -> Result<&'a Repository, HookError>
{ {
debug!("[GIT {} HOOK]: Getting repository", action.uppercase());
runtime runtime
.repository() .repository()
.map_dbg_err_str(on_err_str) .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Repository", action.uppercase()))
.map_dbg(|_| format!("[GIT {} HOOK]: Repository object fetched", action.uppercase()))
.map_err_into(GHEK::RepositoryError) .map_err_into(GHEK::RepositoryError)
.map_into_hook_error() .map_into_hook_error()
} }