fix(sheets): cheatsheets in submodules (#694)

Resolve an issue whereby cheatsheets contained within `git` submodules
were ignored due to a regression introduced in `4.3.1`.
This commit is contained in:
Christopher Allen Lane
2022-08-26 13:14:03 -04:00
parent 5c5ed7344f
commit fd93da799d
2 changed files with 77 additions and 9 deletions

View File

@@ -52,15 +52,11 @@ func Load(cheatpaths []cp.Cheatpath) ([]map[string]sheet.Sheet, error) {
// Don't walk the `.git` directory. Doing so creates
// hundreds/thousands of needless syscalls and could
// potentially harm performance on machines with slow disks.
//
// NB: We _do_ want to walk hidden directories, however, so we
// should not constrain this further (perhaps to include all
// hidden directories). In the wild, many users appear to store
// cheatsheets in a `.config` directory (seemingly a default
// behavior of `brew`), and `cheat` explicitly supports a
// local `.cheat` directory. Constraining further here will
// break those use-cases - and has done so in the past!
if strings.Contains(path, ".git") {
skip, err := isGitDir(path)
if err != nil {
return fmt.Errorf("failed to identify .git directory: %v", err)
}
if skip {
return fs.SkipDir
}