-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(core): recurse into submodule files when crawling git repos #4596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -172,6 +172,8 @@ function withSafeGitConfig(args: string[]): string[] { | |||||||||||||||||||||||||
| 'core.fsmonitor=false', | ||||||||||||||||||||||||||
| '-c', | ||||||||||||||||||||||||||
| 'core.untrackedCache=false', | ||||||||||||||||||||||||||
| '-c', | ||||||||||||||||||||||||||
| 'core.quotePath=false', | ||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
@@ -1036,7 +1038,12 @@ async function crawlWithGitLsFiles( | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Avoid `-z` with `-t`: record shape for `ls-files -t` + `-z` is not stable across Git | ||||||||||||||||||||||||||
| // versions; newline-delimited output is fine here (index paths cannot contain newlines). | ||||||||||||||||||||||||||
| const trackedArgs = ['--literal-pathspecs', 'ls-files', '--cached']; | ||||||||||||||||||||||||||
| const trackedArgs = [ | ||||||||||||||||||||||||||
| '--literal-pathspecs', | ||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Critical] Impact: File search results include ghost entries for deleted submodule files. Downstream consumers (read file, @-mention completion) will get ENOENT errors.
Suggested change
Also: When a submodule is registered but not initialized (common after plain — qwen3.7-max via Qwen Code /review |
||||||||||||||||||||||||||
| 'ls-files', | ||||||||||||||||||||||||||
| '--cached', | ||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] If any submodule is uninitialized or has a broken Consider retrying without if (!trackedResult.success) {
// Retry without --recurse-submodules: broken submodule states can cause
// the recursive listing to fail entirely.
const fallbackArgs = trackedArgs.filter(a => a !== '--recurse-submodules');
const fallbackResult = await commandRunner('git', withSafeGitConfig(fallbackArgs), ...);
if (!fallbackResult.success) {
return { success: false, files: [], gitRepoListingFailed: true };
}
// ... process fallbackResult
}— qwen3.7-max via Qwen Code /review |
||||||||||||||||||||||||||
| '--recurse-submodules', | ||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— qwen3.7-max via Qwen Code /review |
||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||
| trackedArgs.push('-t'); | ||||||||||||||||||||||||||
| if (relativeToGitRoot && relativeToGitRoot !== '.') { | ||||||||||||||||||||||||||
| trackedArgs.push(relativeToGitRoot); | ||||||||||||||||||||||||||
|
|
@@ -1077,6 +1084,16 @@ async function crawlWithGitLsFiles( | |||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let stat: fs.Stats; | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| stat = fs.lstatSync(path.join(gitRoot, ...normalizedFile.split('/'))); | ||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: A lighter alternative: parse Not blocking — the correctness is fine, just something to keep in mind if crawl latency regresses on large monorepos.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] This Consider adding a comment tying the guard to its reason: // --recurse-submodules causes ls-files --cached to emit gitlink entries
// (directory placeholders) for uninitialized submodules. Skip those here.Also, — qwen3.7-max via Qwen Code /review |
||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (stat.isDirectory()) { | ||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||
| relativeToGitRoot && | ||||||||||||||||||||||||||
| relativeToGitRoot !== '.' && | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] This test only asserts that the submodule file appears in results, but doesn't verify that parent-repo files are also present. A regression that drops non-submodule tracked files while returning submodule files would pass undetected.
— qwen3.7-max via Qwen Code /review