/** * Test helper: indexes a pack file using the streaming indexer. * * Replaces the legacy `indexPackOnly` (isomorphic-git) for test seeders. * Uses a no-op limiter and a minimal logger since tests run in miniflare * with no real concurrency or subrequest limits. */ import { scanPack, resolveDeltasAndWriteIdx } from "@/worker/git/pack/indexer"; import { createLogger } from "@/worker/common/logger"; import type { Limiter } from "@/worker/git/operations/limits"; import type { ResolveResult } from "@/worker/git/pack/indexer/types"; import type { PackCatalogRow } from "@/worker/do/repo/db/schema"; const noopLimiter: Limiter = { run: (_label, fn) => fn() }; const testLog = createLogger(undefined, { service: "test-seed" }); /** * Index a pack that is already uploaded to R2. * * Produces a `.idx` file in R2 and returns the resolve result containing * `objectCount` and `idxBytes` needed for `pack_catalog` row insertion. * * Pass `activeCatalog` when the pack contains REF_DELTA objects whose bases * live in previously indexed packs. */ export async function indexTestPack( env: Env, packKey: string, packSize: number, activeCatalog?: PackCatalogRow[] ): Promise { const scanResult = await scanPack({ env, packKey, packSize, limiter: noopLimiter, countSubrequest: () => {}, log: testLog, }); return await resolveDeltasAndWriteIdx({ env, packKey, packSize, limiter: noopLimiter, countSubrequest: () => {}, log: testLog, scanResult, repoId: "test", activeCatalog, }); }