diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-09-07 21:47:39 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-09-07 22:06:07 +0200 |
commit | 4e2a980599a506789b3994545fdbe17fcb858ea2 (patch) | |
tree | 207e4cc183202d3ba355215acf09cf0b1f76e3a9 /libimagstorestdhook/src/vcs/git/util.rs | |
parent | 032110e6d83229a8bc82b6e47f13ce91f155fa14 (diff) |
Refactor Index fetching into helper function
Diffstat (limited to 'libimagstorestdhook/src/vcs/git/util.rs')
-rw-r--r-- | libimagstorestdhook/src/vcs/git/util.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 6bdd954d..7e0a9f4d 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -2,7 +2,7 @@ //! //! Contains primitives to create a repository within the store path -use git2::Repository; +use git2::{Repository, Index}; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; @@ -24,3 +24,12 @@ pub fn fetch_repo<'a>(runtime: &'a GRuntime, action: &StoreAction) -> Result<&'a .map_into_hook_error() } +pub fn fetch_index(repo: &Repository, action: &StoreAction) -> Result<Index, HookError> { + debug!("[GIT {} HOOK]: Getting Index", action.uppercase()); + repo.index() + .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Index", action.uppercase())) + .map_dbg(|_| format!("[GIT {} HOOK]: Index object fetched", action.uppercase())) + .map_err_into(GHEK::RepositoryIndexFetchingError) + .map_into_hook_error() +} + |