Skip to content

Commit

Permalink
Skip all hidden directories, plus node_modules
Browse files Browse the repository at this point in the history
Typically won't contain a repository, for faster searching.
  • Loading branch information
carhartl committed Oct 21, 2024
1 parent 0971d57 commit 1e000f1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/git-unsaved/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"os"
"path/filepath"
"regexp"

"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/spinner"
Expand All @@ -14,6 +15,7 @@ import (
)

var docStyle = lipgloss.NewStyle().Margin(1, 2)
var excludeDirs = regexp.MustCompile(`.+/(\..+|node_modules)`) // Skip hidden directories (incl. .git) and node_modules

type repoMsg struct {
repo repo
Expand Down Expand Up @@ -93,12 +95,14 @@ func getRepos(sub chan repoMsg) tea.Cmd {
if err != nil {
return err
}
if d.IsDir() && filepath.Base(path) == ".git" {
abspath, err := filepath.Abs(path)
if err != nil {
return err
if d.IsDir() && excludeDirs.MatchString(path) {
if filepath.Base(path) == ".git" {
abspath, err := filepath.Abs(path)
if err != nil {
return err
}
sub <- repoMsg{repo: repo{path: filepath.Dir(abspath)}}
}
sub <- repoMsg{repo: repo{path: filepath.Dir(abspath)}}
return fs.SkipDir
}
return nil
Expand Down

0 comments on commit 1e000f1

Please sign in to comment.