Skip to content

Commit d9b4d08

Browse files
committed
fix(discovery): skip hidden directories during workspace scans
Dot-prefixed directories are tool state, caches, and generated fixtures rather than portfolio checkouts, so scanning them manufactured hundreds of anchor findings for synthetic trees. Keep .git as the discoverable boundary while skipping every other dot-directory.
1 parent 1b9a57e commit d9b4d08

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

‎core/discovery/local.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,15 @@ func pathDepth(relative string) int {
306306
}
307307

308308
func excludedDirectory(name string) bool {
309+
// Hidden directories other than a repository's own .git boundary are tool
310+
// state, caches, or generated fixtures (".tmp", ".idea", ".venv", ...) —
311+
// never portfolio checkouts. Scanning them manufactures anchor findings
312+
// for synthetic trees and burns time on ignored content.
313+
if name != ".git" && strings.HasPrefix(name, ".") {
314+
return true
315+
}
309316
switch name {
310-
case ".cache", ".idea", ".pytest_cache", ".ruff_cache", ".tox", ".venv",
311-
"__pycache__", "node_modules", "target", "vendor":
317+
case "__pycache__", "node_modules", "target", "vendor":
312318
return true
313319
default:
314320
return false

‎core/discovery/local_test.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,28 @@ func TestDiscoverAcceptsIdentityPinnedBySuperprojectAndCheckedOutStandalone(t *t
190190
}
191191
}
192192
}
193+
194+
func TestDiscoverSkipsHiddenDirectoryTrees(t *testing.T) {
195+
t.Parallel()
196+
root := t.TempDir()
197+
plain := filepath.Join(root, "plain")
198+
fixture := filepath.Join(root, ".tmp", "native-linux", "fixture-repo")
199+
for _, path := range []string{plain, fixture} {
200+
if err := os.MkdirAll(path, 0o755); err != nil {
201+
t.Fatal(err)
202+
}
203+
if output, err := exec.Command("git", "init", "-q", path).CombinedOutput(); err != nil {
204+
t.Fatalf("git init %s: %v\n%s", path, err, output)
205+
}
206+
}
207+
208+
result, err := newTestDiscovery(t).Discover(
209+
context.Background(), root, Options{MaxDepth: 8, MaxRepositories: 10, Concurrency: 2},
210+
)
211+
if err != nil {
212+
t.Fatalf("Discover() error = %v", err)
213+
}
214+
if len(result.Boundaries) != 1 || result.Boundaries[0].Path != plain {
215+
t.Fatalf("boundaries = %#v, want only %s", result.Boundaries, plain)
216+
}
217+
}

0 commit comments

Comments
 (0)