From f0d3c6418bfc78c917942d33461de965eff05590 Mon Sep 17 00:00:00 2001 From: Dries De Peuter Date: Fri, 3 Jul 2026 22:29:08 +0200 Subject: [PATCH] fix: Speed up repo discovery with parallel traversal Walk sibling directories concurrently instead of draining each child sequentially, and match excludeDirs against the child path so exclusions actually prune subtrees. --- internal/pkg/repo/discover.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/internal/pkg/repo/discover.go b/internal/pkg/repo/discover.go index f54601d..453c182 100644 --- a/internal/pkg/repo/discover.go +++ b/internal/pkg/repo/discover.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "strings" + "sync" "github.com/spf13/viper" ) @@ -48,22 +49,28 @@ func GetRepoPathsChan(basedir string, includeExtras bool) <-chan string { if !entry.IsDir() { continue } - if inExcludeList(basedir) { - continue - } if entry.Name() == ".git" { out <- basedir return } - subdirs = append(subdirs, entry.Name()) + child := fmt.Sprintf("%s/%s", basedir, entry.Name()) + if inExcludeList(child) { + continue + } + subdirs = append(subdirs, child) } - for _, subdir := range subdirs { - subchan := GetRepoPathsChan(fmt.Sprintf("%s/%s", basedir, subdir), false) - for p := range subchan { - out <- p - } + var wg sync.WaitGroup + for _, child := range subdirs { + wg.Add(1) + go func(dir string) { + defer wg.Done() + for p := range GetRepoPathsChan(dir, false) { + out <- p + } + }(child) } + wg.Wait() }() return out