fix: honor --repo pointing at a module's own .code-review-graph dir#701
Open
Khusan-Khujakeldiev wants to merge 1 commit into
Open
Conversation
search/query/impact (and other _GRAPH_TOOL_COMMANDS) resolved an explicit --repo via find_project_root(), which only walks *up* looking for .git/.svn. In a monorepo with a single .git at the root and independently build/register-ed module subdirectories (each carrying its own .code-review-graph marker but no .git of their own, e.g. llvm-project's llvm/ and clang/), this silently climbed past the module's own graph to the monorepo root and reported 'No graph found' even though the graph existed exactly where --repo pointed. Now, when --repo points directly at a directory that already has its own .code-review-graph subdirectory, that path is honored as-is instead of being used only as a starting point for the upward git-root walk. This mirrors how build/register/status already treat .code-review-graph as sufficient evidence of a project root via tools._common._validate_repo_root. No change when --repo has no .code-review-graph of its own (falls through to the existing find_project_root walk), so existing subdirectory-of-a- single-repo behavior is unaffected. Adds a regression test that reproduces the monorepo shape and asserts search --repo <module> resolves to <module>, not an ancestor with .git. Co-authored-by: Cursor <cursoragent@cursor.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.
Fixes #697.
Problem
search/query/impact(and the rest of_GRAPH_TOOL_COMMANDS) resolve anexplicit
--repoviafind_project_root(), which only walks up looking for.git/.svn. In a monorepo with a single.gitat the root and independentlybuild/register-ed module subdirectories (each carrying its own.code-review-graphmarker but no.gitof their own — e.g.llvm-project'sllvm/andclang/), this silently climbs past the module's own graph to themonorepo root and reports "No graph found" even though the graph exists
exactly where
--repopointed.Fix
When
--repopoints directly at a directory that already has its own.code-review-graphsubdirectory, honor that path as-is instead of using itonly as a starting point for the upward git-root walk. This mirrors how
build/register/statusalready treat.code-review-graphas sufficientevidence of a project root via
tools._common._validate_repo_root.When
--repohas no.code-review-graphof its own, behavior is unchanged(falls through to the existing
find_project_rootwalk), so the existing"nested subdirectory of a single repo" case is unaffected.
Testing
test_tool_command_honors_repo_flag_over_ancestor_git_in_monorepo,which reproduces the monorepo shape (one
.gitat the top, a modulesubdirectory with its own
.code-review-graph/graph.db) and assertssearch --repo <module>resolves to<module>, not the ancestor with.git. Verified it fails onmainand passes with this fix.no new failures (only pre-existing, unrelated Windows-only failures around
chmod/symlinkprivileges and git submodule fixtures remain, present onmaintoo).~180K-file
llvm-projectcheckout built/registered module-by-module withCRG, where
search/query callers_of/impact --filesnow return correctresults with
--repopointing at a module (e.g. the largest module,llvm/, ~80K files).