From 40bd7f69d97f5ce8bea747ae6598d1b0b7601bb1 Mon Sep 17 00:00:00 2001 From: Marcel Schneider Date: Tue, 29 Jun 2021 12:48:45 +0200 Subject: [PATCH] Don't skip files when checking for root folder Submodules don't have a .git folder, but only a file. Fixes #7 --- src/helpers.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index f985a9b..cedfd3c 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -49,7 +49,10 @@ pub struct BoilerplateOpts { pub timestamp: Option, } -/// 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 { 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);