diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-09-20 15:18:51 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-09-20 15:19:35 +0200 |
commit | 5085d752084541522350c324997e36e3cd6ee509 (patch) | |
tree | 08b01e949cfbbf715537a7da1232d765d158f5ac /libimagstorestdhook/src | |
parent | 9dc4054a92f01343df61ef28a6b21b24d064b377 (diff) |
Return if the file is not new and not modified
Diffstat (limited to 'libimagstorestdhook/src')
-rw-r--r-- | libimagstorestdhook/src/vcs/git/update.rs | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 065191c7..fc8d451b 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -129,6 +129,26 @@ impl StoreIdAccessor for UpdateHook { let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); let repo = try!(self.runtime.repository(&action)); + + let file_status = try!( + repo + .status_file(id.local()) + .map_dbg_err_str("Failed to fetch file status") + .map_dbg_err(|e| format!("\t-> {:?}", e)) + .map_dbg_str("[GIT UPDATE HOOK]: Fetched file status") + .map_err_into(GHEK::RepositoryFileStatusError) + .map_into_hook_error() + ); + + debug!("File status: STATUS_WT_NEW = {}", file_status.contains(STATUS_WT_NEW)); + debug!("File status: STATUS_WT_MODIFIED = {}", file_status.contains(STATUS_WT_MODIFIED)); + + if !file_status.contains(STATUS_WT_NEW) && !file_status.contains(STATUS_WT_MODIFIED) { + // File seems to be unmodified and not new. This means that the file is already + // committed and we can return here. + return Ok(()) + } + let mut index = try!(fetch_index(repo, &action)); let signature = try!( @@ -147,19 +167,6 @@ impl StoreIdAccessor for UpdateHook { .map_into_hook_error() ); - let file_status = try!( - repo - .status_file(id.local()) - .map_dbg_err_str("Failed to fetch file status") - .map_dbg_err(|e| format!("\t-> {:?}", e)) - .map_dbg_str("[GIT UPDATE HOOK]: Fetched file status") - .map_err_into(GHEK::RepositoryFileStatusError) - .map_into_hook_error() - ); - - debug!("File status: STATUS_WT_NEW = {}", file_status.contains(STATUS_WT_NEW)); - debug!("File status: STATUS_WT_MODIFIED = {}", file_status.contains(STATUS_WT_MODIFIED)); - let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { if file_status.contains(STATUS_WT_NEW) || file_status.contains(STATUS_WT_MODIFIED) { debug!("[GIT CREATE HOOK]: File is modified/new: {}", path.display()); |