Return if the file is not new and not modified
This commit is contained in:
parent
9dc4054a92
commit
5085d75208
1 changed files with 20 additions and 13 deletions
|
@ -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,19 +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()
|
|
||||||
);
|
|
||||||
|
|
||||||
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 {
|
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());
|
||||||
|
|
Loading…
Reference in a new issue