test(pr): reuse repeated merge fixture histories (#162816)

Cache uncustomized source-version sequences in the existing immutable Git fixture template. Each case retains private refs, index, objects, remote and worktree; custom attribution and promisor clones stay fresh.

Crabbox A-B-B-A passed all 48 cases per arm: candidates 69.04-72.01s versus baselines 75.80s and 94.83s. Baseline drift limits percentage precision. The target, 167 sibling cases and all 18 selected checks passed.

Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
Peter Steinberger 2026-10-01 10:17:26 -07:00 • committed by GitHub
parent b0324be63c
commit f05948c9a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -61,7 +61,7 @@ export function createMergeGitFixtureFactory(directory: string, gitEnv: NodeJS.P
const base = seed.commit(seed.tree("before\n"), []);
seed.git(["update-ref", "refs/heads/main", base]);
const copyOptions = { recursive: true, mode: fsConstants.COPYFILE_FICLONE };
let prepared: ReturnType<typeof createSourceFixture> | undefined;
const preparedSources = new Map<string, ReturnType<typeof createSourceFixture>>();
function createSourceFixture(
fixtureRoot: string,
@ -136,15 +136,8 @@ export function createMergeGitFixtureFactory(directory: string, gitEnv: NodeJS.P
promisor = false,
sourceAuthor?: { name: string; email: string },
) => {
// Attribution, multi-commit and filtered-clone cases still construct their own source history.
if (
sourceMessage !== undefined ||
sourceAuthor !== undefined ||
promisor ||
sourceVersions.length !== 1 ||
sourceVersions[0]?.[0] !== "after\n" ||
sourceVersions[0]?.[1] !== undefined
) {
// Attribution and filtered-clone cases still construct their own source history.
if (sourceMessage !== undefined || sourceAuthor !== undefined || promisor) {
return createSourceFixture(
fixtureRoot,
sourceMessage,
@ -153,10 +146,13 @@ export function createMergeGitFixtureFactory(directory: string, gitEnv: NodeJS.P
sourceAuthor,
);
}
const sourceKey = JSON.stringify(sourceVersions);
let prepared = preparedSources.get(sourceKey);
if (!prepared) {
const preparedRoot = join(root, "prepared");
const preparedRoot = join(root, `prepared-${preparedSources.size}`);
mkdirSync(preparedRoot);
prepared = createSourceFixture(preparedRoot);
prepared = createSourceFixture(preparedRoot, undefined, sourceVersions);
preparedSources.set(sourceKey, prepared);
}
const fixtureRepo = join(fixtureRoot, "repo");
const fixtureRemote = join(fixtureRoot, "remote.git");