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

Function findIgnoredEmbeddedRepos

src/extraction/index.ts:1307–1330  ·  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

1305 * default excludes (`node_modules`, …) are always skipped.
1306 */
1307function findIgnoredEmbeddedRepos(repoDir: string, includeIgnored: Ignore | null, prefix: string): string[] {
1308 if (!includeIgnored) return [];
1309 const defaults = defaultsOnlyIgnore();
1310 const repos: string[] = [];
1311 for (const dir of listIgnoredDirs(repoDir)) {
1312 if (defaults.ignores(dir)) continue;
1313 const nested = findNestedGitRepos(path.join(repoDir, dir), dir);
1314 if (includeIgnored.ignores(normalizePath(prefix + dir))) {
1315 // The whole ignored dir is opted in — every nested repo under it counts.
1316 repos.push(...nested);
1317 } else {
1318 // A single gitignore rule often covers the PARENT of the opted-in
1319 // repos: `.gitignore: /repos/` lists `repos/` as ONE ignored entry,
1320 // while `includeIgnored: ["repos/a/"]` (the CLI hint's own suggested
1321 // spelling) names the child — which never matches the parent path, so
1322 // the opt-in silently did nothing (#1295). Match each nested repo
1323 // root individually so both spellings work. The walk is bounded
1324 // (depth/entry caps in findNestedGitRepos) and only runs when
1325 // includeIgnored is configured at all.
1326 repos.push(...nested.filter((r) => includeIgnored.ignores(normalizePath(prefix + r))));
1327 }
1328 }
1329 return repos;
1330}
1331
1332/**
1333 * `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