Fix git submodule path cache retention (#7687)

This commit is contained in:
Neil
2026-07-11 01:30:19 -07:00
committed by GitHub
parent d912482752
commit acb35ee649
18 changed files with 807 additions and 112 deletions
+41
View File
@@ -30,6 +30,10 @@ import {
removeWorktree
} from '../git/worktree'
import * as gitRunner from '../git/runner'
import {
clearSubmodulePathsCacheForTests,
listSubmodulePaths
} from '../git/status'
import {
createSetupRunnerScript,
getEffectiveHooks,
@@ -6182,6 +6186,43 @@ describe('OrcaRuntimeService', () => {
}
})
it('drops a same-path negative submodule cache before runtime cloneRepo', async () => {
const spawnSpy = vi.spyOn(gitRunner, 'gitSpawn')
const destination = await mkdtemp(join(tmpdir(), 'orca-runtime-reclone-'))
const clonePath = join(destination, 'reclone')
const added: Record<string, unknown>[] = []
const cloneStore = {
...store,
getRepos: () => [...added] as never,
addRepo: (repo: Record<string, unknown>) => added.push(repo),
getRepo: (id: string) => added.find((repo) => repo.id === id) as never
}
spawnSpy.mockImplementation(() => {
const proc = new EventEmitter() as EventEmitter & { stderr: EventEmitter }
proc.stderr = new EventEmitter()
queueMicrotask(() => {
void mkdir(clonePath, { recursive: true })
.then(() =>
writeFile(join(clonePath, '.gitmodules'), '[submodule "lib"]\n\tpath = vendor/lib\n')
)
.then(() => proc.emit('close', 0, null))
})
return proc as never
})
const runtime = new OrcaRuntimeService(cloneStore as never)
try {
clearSubmodulePathsCacheForTests()
await expect(listSubmodulePaths(clonePath)).resolves.toEqual([])
await runtime.cloneRepo('https://example.com/reclone.git', destination)
await expect(listSubmodulePaths(clonePath)).resolves.toEqual(['vendor/lib'])
} finally {
clearSubmodulePathsCacheForTests()
spawnSpy.mockRestore()
await rm(destination, { recursive: true, force: true })
}
})
it('preserves existing badgeColor on runtime cloneRepo folder->git dedupe upgrade', async () => {
const spawnSpy = vi.spyOn(gitRunner, 'gitSpawn')
spawnSpy.mockImplementation(() => {