merge: bound Gateway scenario git fan-out

This commit is contained in:
2026-08-04 16:42:18 +00:00
2 changed files with 17 additions and 1 deletions
@@ -62,6 +62,9 @@ const runGit = (args: string[]): Promise<{ ok: boolean; output: string }> =>
child.stderr.on('data', (chunk) => { child.stderr.on('data', (chunk) => {
output += chunk.toString(); output += chunk.toString();
}); });
child.on('error', (error) => {
resolve({ ok: false, output: `${output}${error.message}` });
});
child.on('close', (code) => { child.on('close', (code) => {
resolve({ ok: code === 0, output }); resolve({ ok: code === 0, output });
}); });
@@ -308,7 +311,10 @@ export const listScenarioPreviews = async (options?: { gitRef?: string | null })
return cached.data; return cached.data;
} }
const ids = await listScenarioIdsFromGit(commitSha); const ids = await listScenarioIdsFromGit(commitSha);
const previews = await Promise.all(ids.map((id) => buildScenarioPreviewFromGit(commitSha, id))); const previews: ScenarioPreview[] = [];
for (const id of ids) {
previews.push(await buildScenarioPreviewFromGit(commitSha, id));
}
previewCache.set(cacheKey, { previewCache.set(cacheKey, {
loadedAt: Date.now(), loadedAt: Date.now(),
data: previews, data: previews,
@@ -15,4 +15,14 @@ describe('scenarioCatalog git ref support', () => {
const sorted = [...ids].sort((a, b) => a - b); const sorted = [...ids].sort((a, b) => a - b);
expect(ids).toEqual(sorted); expect(ids).toEqual(sorted);
}); });
it('rejects without crashing when git cannot be spawned', async () => {
const originalPath = process.env.PATH;
process.env.PATH = '/nonexistent';
try {
await expect(resolveGitCommitSha('HEAD')).rejects.toThrow('git ref not found.');
} finally {
process.env.PATH = originalPath;
}
});
}); });