mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(cli): limit concurrent git processes for untracked files
This commit is contained in:
@@ -376,19 +376,23 @@ export namespace Review {
|
||||
const untracked = await $`git ls-files --others --exclude-standard -z`.cwd(Instance.directory).quiet().nothrow()
|
||||
if (untracked.exitCode === 0) {
|
||||
const paths = untracked.stdout.toString().split("\0").filter(Boolean)
|
||||
// Run diffs in parallel — sequential spawns are slow with many untracked files
|
||||
const diffs = await Promise.all(
|
||||
paths.map((p) =>
|
||||
// --no-index exits 1 when files differ, which is expected
|
||||
$`git -c core.quotepath=false diff --no-index -- /dev/null ${p}`
|
||||
.cwd(Instance.directory)
|
||||
.quiet()
|
||||
.nothrow()
|
||||
.then((fd) => fd.stdout.toString()),
|
||||
),
|
||||
)
|
||||
for (const out of diffs) {
|
||||
if (out) raw += out
|
||||
// Process in batches to avoid spawning hundreds of git processes
|
||||
const batch = 20
|
||||
for (let i = 0; i < paths.length; i += batch) {
|
||||
const chunk = paths.slice(i, i + batch)
|
||||
const diffs = await Promise.all(
|
||||
chunk.map((p) =>
|
||||
// --no-index exits 1 when files differ, which is expected
|
||||
$`git -c core.quotepath=false diff --no-index -- /dev/null ${p}`
|
||||
.cwd(Instance.directory)
|
||||
.quiet()
|
||||
.nothrow()
|
||||
.then((fd) => fd.stdout.toString()),
|
||||
),
|
||||
)
|
||||
for (const out of diffs) {
|
||||
if (out) raw += out
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user