Skip to content

Commit

Permalink
fix: Make repo discovery quicker
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Dec 30, 2023
1 parent 977f10e commit e26603f
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions internal/pkg/repo/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@ import (
)

func GetRepoPaths(baseDir string) ([]string, error) {
result := []string{}
if err := filepath.Walk(baseDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("failed to walk path %s: %w", path, err)
}
if !info.IsDir() {
return nil
}
relPath, err := filepath.Rel(baseDir, path)
if err != nil {
return fmt.Errorf("failed to get relative path for %s: %w", path, err)
}
if info.Name() != ".git" {
return nil
}

result = append(result, filepath.Dir(relPath))

return err
}); err != nil {
return nil, err
}

return result, nil
result := []string{}

entries, err := os.ReadDir(baseDir)
if err != nil {
return result, err
}

for _, entry := range entries {
if !entry.IsDir() {
continue
}

if entry.Name() == ".git" {
return []string{baseDir}, nil
}

paths, err := GetRepoPaths(fmt.Sprintf("%s/%s", baseDir, entry.Name()))
if err != nil {
return result, err
}

result = append(result, paths...)
}

return result, nil
}

0 comments on commit e26603f

Please sign in to comment.