Browse Source

Don't skip files when checking for root folder

Submodules don't have a .git folder, but only a file.
Fixes #7
master
Schneider 4 years ago
parent
commit
40bd7f69d9
Signed by: schneider GPG Key ID: 3F50B02A50039F3B
  1. 12
      src/helpers.rs

12
src/helpers.rs

@ -49,7 +49,10 @@ pub struct BoilerplateOpts {
pub timestamp: Option<stderrlog::Timestamp>,
}
/// Checks if the given dir contains the root `.git` dir
/// Checks if the given dir contains the root `.git` dir or file
///
/// Submodules do not contain a complete .git directory, but only a .git file with a reference to
/// the actual folder. This function takes both into account.
///
/// # Errors
///
@ -60,13 +63,6 @@ fn has_git_dir(path: &PathBuf) -> Result<bool> {
git.push(".git");
for entry in path.read_dir().chain_err(|| "Reading contents of dir")? {
if let Ok(entry) = entry {
// skip non-directories
if let Ok(ft) = entry.file_type() {
if !ft.is_dir() {
continue;
}
}
// check if this is `.git`
if entry.path() == git {
return Ok(true);

Loading…
Cancel
Save