fix: index embedded git repos hidden by the super-repo .gitignore#623
Open
kaito1337 wants to merge 1 commit into
Open
fix: index embedded git repos hidden by the super-repo .gitignore#623kaito1337 wants to merge 1 commit into
kaito1337 wants to merge 1 commit into
Conversation
collectGitFiles only recurses into embedded (non-submodule) repos that surface as untracked entries via `git ls-files -o --exclude-standard`. When the super-repo's own .gitignore excludes a nested clone — common in workspaces that hold independent repos and ignore them to keep their own `git status` clean — the repo never appears there, so none of its source is indexed. Wrapper dirs (a plain dir holding sibling clones) are missed for the same reason. Add a pass over ignored directories (`git ls-files -o -i --exclude-standard --directory`) and recurse into any that is, or contains, a git repo. Files from these repos are filtered only by the built-in defaults (node_modules, ...), not the super-repo's .gitignore: that exclusion is the parent's tracking hygiene, and each embedded repo still honors its OWN .gitignore inside collectGitFiles. Complements the untracked-embedded-repo handling from colbymchenry#193. Closes colbymchenry#622. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #622.
Problem
When a workspace is itself a git repo whose own
.gitignoreexcludes the nestedclones it holds,
codegraphindexes none of that nested source. Theembedded-repo recursion from #193 only fires for repos that surface as
untracked entries (
git ls-files -o --exclude-standard), so a nested repo thesuper-repo ignores stays invisible — as does a plain wrapper dir (e.g.
services/) that merely holds sibling clones.Real-world: a 17-service Go monorepo (
go.work, eachservices/*/shared/its own clone, all excluded by the root
.gitignoreto keepgit statusclean)indexed 3 files / 0 symbols.
Fix
src/extraction/index.ts:git ls-files -o -i --exclude-standard --directory— recursing into any entry that is, or contains, a git repo(
findEmbeddedReposUnder+collectIgnoredEmbeddedRepos). Wrapper dirs aredescended a bounded depth;
DEFAULT_IGNORE_DIRSand dot-dirs are skipped.(
node_modules, …), not the super-repo's.gitignore— that exclusion isthe parent's tracking hygiene. Each embedded repo still honors its own
.gitignoreinsidecollectGitFiles.Consistent with the intent of #193 (embedded repos) and #147 (submodules):
nested project boundaries get indexed; the only gap was the ignored ones.
Tests
3 regression tests added to the existing
Nested non-submodule git reposblock:ignored embedded repo, ignored wrapper dir with sibling repos, and a hidden
repo's own
.gitignorestill being honored.tscbuild clean; the gitignore/submodule/embedded suites still pass.Verified on the real monorepo
The patched scanner takes the layout above from 3 → 658 source files
(516
services/, 139shared/, 616.go) without any change to its.gitignore.Known follow-up (out of scope)
Incremental sync via
git status --porcelainon the super-repo won't see editsinside an ignored embedded repo; the filesystem watcher backstops live updates
and a full re-index always picks them up. Flagged in #622 for a separate look.