2 Commits

Author SHA1 Message Date
Schneider 2f827c3f68
v0.2.3 3 years ago
Schneider 40bd7f69d9
Don't skip files when checking for root folder 3 years ago
  1. 2
      Cargo.toml
  2. 12
      src/helpers.rs

2
Cargo.toml

@ -1,6 +1,6 @@
[package]
name = "gitig"
version = "0.2.2"
version = "0.2.3"
authors = ["Marcel Schneider <gitig@webschneider.org>"]
description = "A cli utility to manage gitignore files easily"
edition = "2018"

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