Merge pull request #758 from matthiasbeyer/libimagstorestdhook/git-fix-empty-commits

libimagstorestdhook/git: fix empty commits
This commit is contained in:
Matthias Beyer 2016-09-20 17:10:21 +02:00 committed by GitHub
commit 90bb61674f

View file

@ -129,6 +129,26 @@ impl StoreIdAccessor for UpdateHook {
let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action));
let repo = try!(self.runtime.repository(&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 mut index = try!(fetch_index(repo, &action));
let signature = try!( let signature = try!(
@ -147,16 +167,6 @@ impl StoreIdAccessor for UpdateHook {
.map_into_hook_error() .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()
);
let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 {
if file_status.contains(STATUS_WT_NEW) || file_status.contains(STATUS_WT_MODIFIED) { if file_status.contains(STATUS_WT_NEW) || file_status.contains(STATUS_WT_MODIFIED) {
debug!("[GIT CREATE HOOK]: File is modified/new: {}", path.display()); debug!("[GIT CREATE HOOK]: File is modified/new: {}", path.display());