diff --git a/src/git.rs b/src/git.rs index c4d27d2e..b1ba21e5 100644 --- a/src/git.rs +++ b/src/git.rs @@ -21,9 +21,16 @@ impl Git { pub fn get_repo_root>(&self, path: P) -> Option { match path.as_ref().canonicalize() { - Ok(path) => { + Ok(mut path) => { debug_assert!(path.exists()); + if path.is_file() { + debug!("{} is a file. Checking {}", path.display(), path.parent()?.display()); + path = path.parent()?.to_path_buf(); + } + + debug!("Checking if {} is a git repository", path.display()); + if let Some(git) = &self.git { let output = Command::new(&git) .arg("rev-parse")