MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / findIgnoredEmbeddedRepos

Function findIgnoredEmbeddedRepos

src/extraction/index.ts:1323–1346  ·  view source on GitHub ↗

* Discover embedded repos hidden by `repoDir`'s OWN gitignore rules: for each * gitignored directory, search for nested `.git` roots. Returns repo paths * relative to `repoDir`, trailing-slashed. * * OPT-IN ONLY. Walking into a gitignored directory contradicts what every other * tool (and CodeG

(repoDir: string, includeIgnored: Ignore | null, prefix: string)

Source from the content-addressed store, hash-verified

1321 * default excludes (`node_modules`, …) are always skipped.
1322 */
1323function findIgnoredEmbeddedRepos(repoDir: string, includeIgnored: Ignore | null, prefix: string): string[] {
1324 if (!includeIgnored) return [];
1325 const defaults = defaultsOnlyIgnore();
1326 const repos: string[] = [];
1327 for (const dir of listIgnoredDirs(repoDir)) {
1328 if (defaults.ignores(dir)) continue;
1329 const nested = findNestedGitRepos(path.join(repoDir, dir), dir);
1330 if (includeIgnored.ignores(normalizePath(prefix + dir))) {
1331 // The whole ignored dir is opted in — every nested repo under it counts.
1332 repos.push(...nested);
1333 } else {
1334 // A single gitignore rule often covers the PARENT of the opted-in
1335 // repos: `.gitignore: /repos/` lists `repos/` as ONE ignored entry,
1336 // while `includeIgnored: ["repos/a/"]` (the CLI hint's own suggested
1337 // spelling) names the child — which never matches the parent path, so
1338 // the opt-in silently did nothing (#1295). Match each nested repo
1339 // root individually so both spellings work. The walk is bounded
1340 // (depth/entry caps in findNestedGitRepos) and only runs when
1341 // includeIgnored is configured at all.
1342 repos.push(...nested.filter((r) => includeIgnored.ignores(normalizePath(prefix + r))));
1343 }
1344 }
1345 return repos;
1346}
1347
1348/**
1349 * `git ls-files -z -s -t`, expanding submodules where git allows it.

Callers 3

visitFunction · 0.85
collectGitFilesFunction · 0.85
collectGitStatusFunction · 0.85

Calls 7

normalizePathFunction · 0.90
defaultsOnlyIgnoreFunction · 0.85
listIgnoredDirsFunction · 0.85
findNestedGitReposFunction · 0.85
ignoresMethod · 0.80
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected