Return if the file is not new and not modified

This commit is contained in:
Matthias Beyer 2016-09-20 15:18:51 +02:00
parent 9dc4054a92
commit 5085d75208

View file

@ -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());