diff options
Diffstat (limited to 'src/util/git.rs')
-rw-r--r-- | src/util/git.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/util/git.rs b/src/util/git.rs index 8ac163e..628e511 100644 --- a/src/util/git.rs +++ b/src/util/git.rs @@ -18,9 +18,16 @@ use git2::Repository; use log::trace; pub fn repo_is_clean(p: &Path) -> Result<bool> { - Repository::open(p) + let r = Repository::open(p)?; + + r.diff_index_to_workdir(None, None) + .and_then(|d| d.stats()) .map_err(Error::from) - .map(|r| r.state() == git2::RepositoryState::Clean) + .map(|st| { + trace!("Repo stats: {:?}", st); + trace!("Repo state: {:?}", r.state()); + st.files_changed() == 0 && r.state() == git2::RepositoryState::Clean + }) } pub fn get_repo_head_commit_hash(p: &Path) -> Result<String> { |