From 31fe024e936cdacf84719bee223ccbaab34ff528 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 17 Aug 2026 02:43:30 -0700 Subject: [PATCH] test: make pack fixture deterministic via git pack-objects Incremental 'git repack' consolidates small packs on newer git builds (CI produced 3 packs from 6 commits), making the sprawl fixture count nondeterministic. pack-objects with an explicit sha per commit creates exactly one pack each on every git version. --- tests/cli/test_worktree_selfheal.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/cli/test_worktree_selfheal.py b/tests/cli/test_worktree_selfheal.py index 9afed83464..b81ffe7987 100644 --- a/tests/cli/test_worktree_selfheal.py +++ b/tests/cli/test_worktree_selfheal.py @@ -92,13 +92,21 @@ class TestMaintainPackHealth: return len(list((repo / ".git" / "objects" / "pack").glob("*.pack"))) def _make_packs(self, repo, n): - """Create n distinct packs by committing + repacking incrementally.""" + """Create exactly n distinct packs via git pack-objects (deterministic + across git versions — incremental `git repack` consolidates small + packs on newer CI git builds, which made the count nondeterministic).""" + pack_dir = repo / ".git" / "objects" / "pack" + pack_dir.mkdir(parents=True, exist_ok=True) for i in range(n): (repo / f"p{i}.txt").write_text(f"{i}\n") _git(repo, "add", "-A") _git(repo, "commit", "-qm", f"c{i}") - # `repack` without -a packs only loose objects → one new pack. - _git(repo, "repack", "-q") + sha = _git(repo, "rev-parse", f"HEAD^{{commit}}").stdout.strip() + # One pack per commit object: pipe the sha into pack-objects. + subprocess.run( + ["git", "pack-objects", "-q", str(pack_dir / f"tpack{i}")], + input=f"{sha}\n", cwd=str(repo), capture_output=True, text=True, check=True, + ) return self._pack_count(repo) def test_repacks_at_threshold(self, repo, monkeypatch):