Merge pull request #757 from matthiasbeyer/libimagstorestdhook/git-revert-no-commit-on-clean-wd
libimagstorestdhook/git revert no commit on clean wd
This commit is contained in:
commit
5a6d8adc55
2 changed files with 1 additions and 28 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use git2::{Index, Repository};
|
use git2::Repository;
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
use libimagerror::into::IntoError;
|
use libimagerror::into::IntoError;
|
||||||
|
@ -155,25 +155,5 @@ impl Runtime {
|
||||||
.map_dbg(|_| format!("[GIT {} HOOK]: Branch checked out", action.uppercase()))
|
.map_dbg(|_| format!("[GIT {} HOOK]: Branch checked out", action.uppercase()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether the WD is "dirty" - whether there is a diff to the repository
|
|
||||||
/// This function returns false if there is no `Repository` object in the `Runtime`
|
|
||||||
pub fn repo_is_dirty(&self, index: &Index) -> bool {
|
|
||||||
match self.repository.as_ref() {
|
|
||||||
Some(repo) => {
|
|
||||||
repo.diff_index_to_workdir(Some(index), None)
|
|
||||||
.map_dbg_str("Fetched diff: Index <-> WD")
|
|
||||||
.map_dbg_err_str("Failed to fetch diff: Index <-> WD")
|
|
||||||
.map(|diff| diff.deltas().count() != 0)
|
|
||||||
.unwrap_or(false)
|
|
||||||
},
|
|
||||||
|
|
||||||
None => {
|
|
||||||
debug!("No repository: Cannot fetch diff: Index <-> WD");
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,13 +131,6 @@ impl StoreIdAccessor for UpdateHook {
|
||||||
let repo = try!(self.runtime.repository(&action));
|
let repo = try!(self.runtime.repository(&action));
|
||||||
let mut index = try!(fetch_index(repo, &action));
|
let mut index = try!(fetch_index(repo, &action));
|
||||||
|
|
||||||
if !self.runtime.repo_is_dirty(&index) {
|
|
||||||
debug!("[GIT UPDATE HOOK]: Repository seems to be clean. I'm done.");
|
|
||||||
return Ok(())
|
|
||||||
} else {
|
|
||||||
debug!("[GIT UPDATE HOOK]: Repository seems to be dirty. Continuing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
let signature = try!(
|
let signature = try!(
|
||||||
repo.signature()
|
repo.signature()
|
||||||
.map_err_into(GHEK::MkSignature)
|
.map_err_into(GHEK::MkSignature)
|
||||||
|
|
Loading…
Reference in a new issue