findNestedGitRepos returns subdirectory names that contain their own .git These are separate repositories (not submodules) that should be excluded from scanning to avoid hanging on large nested repos.
(root string)
| 189 | // These are separate repositories (not submodules) that should be excluded |
| 190 | // from scanning to avoid hanging on large nested repos. |
| 191 | func findNestedGitRepos(root string) []string { |
| 192 | entries, err := os.ReadDir(root) |
| 193 | if err != nil { |
| 194 | return nil |
| 195 | } |
| 196 | |
| 197 | var repos []string |
| 198 | for _, e := range entries { |
| 199 | if !e.IsDir() || strings.HasPrefix(e.Name(), ".") { |
| 200 | continue |
| 201 | } |
| 202 | gitPath := filepath.Join(root, e.Name(), ".git") |
| 203 | if info, err := os.Stat(gitPath); err == nil && info.IsDir() { |
| 204 | repos = append(repos, e.Name()) |
| 205 | } |
| 206 | } |
| 207 | return repos |
| 208 | } |
| 209 | |
| 210 | // ScanDirectory analyzes all files in a directory using sg scan |
| 211 | func (s *AstGrepScanner) ScanDirectory(root string) ([]FileAnalysis, error) { |