walkDirectory recursively collects files from a directory, skipping known junk directories.
(dir, projectRoot, source string, seen map[string]bool)
| 189 | |
| 190 | // walkDirectory recursively collects files from a directory, skipping known junk directories. |
| 191 | func walkDirectory(dir, projectRoot, source string, seen map[string]bool) []FileEntry { |
| 192 | var result []FileEntry |
| 193 | _ = filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error { |
| 194 | if err != nil { |
| 195 | return nil |
| 196 | } |
| 197 | if d.IsDir() { |
| 198 | if skipDirs[d.Name()] { |
| 199 | return filepath.SkipDir |
| 200 | } |
| 201 | return nil |
| 202 | } |
| 203 | rel, relErr := filepath.Rel(projectRoot, path) |
| 204 | if relErr != nil || seen[rel] { |
| 205 | return nil |
| 206 | } |
| 207 | seen[rel] = true |
| 208 | result = append(result, FileEntry{ |
| 209 | Path: rel, |
| 210 | Source: source, |
| 211 | Exists: true, |
| 212 | }) |
| 213 | return nil |
| 214 | }) |
| 215 | return result |
| 216 | } |
| 217 | |
| 218 | // filterGitIgnored removes gitignored files from the list using git check-ignore. |
| 219 | // Falls back gracefully (returns input unchanged) if git is unavailable or the project is not a repo. |
no test coverage detected