MCPcopy Create free account
hub / github.com/libgit2/pygit2 / confirm_same_repo_after_packing

Function confirm_same_repo_after_packing

test/test_packbuilder.py:92–118  ·  view source on GitHub ↗
(
    testrepo: Repository,
    tmp_path: Path,
    pack_delegate: Callable[[PackBuilder], None] | None,
)

Source from the content-addressed store, hash-verified

90
91
92def confirm_same_repo_after_packing(
93 testrepo: Repository,
94 tmp_path: Path,
95 pack_delegate: Callable[[PackBuilder], None] | None,
96) -> None:
97 # Helper method to confirm the contents of two repos before and after packing
98 pack_repo = setup_second_repo(tmp_path)
99 pack_repo_path = Path(pack_repo.path)
100
101 objects_dir = pack_repo_path / 'objects'
102 utils.rmtree(objects_dir)
103 pack_path = objects_dir / 'pack'
104 pack_path.mkdir(parents=True)
105
106 # assert that the number of written objects is the same as the number of objects in the repo
107 written_objects = testrepo.pack(pack_path, pack_delegate=pack_delegate)
108 assert written_objects == len([obj for obj in testrepo])
109
110 # assert that the number of objects in the pack repo is the same as the original repo
111 orig_objects = [obj for obj in testrepo.odb]
112 packed_objects = [obj for obj in pack_repo.odb]
113 assert len(packed_objects) == len(orig_objects)
114
115 # assert that the objects in the packed repo are the same objects as the original repo
116 for i, obj in enumerate(orig_objects):
117 assert pack_repo[obj].type == testrepo[obj].type
118 assert pack_repo[obj].read_raw() == testrepo[obj].read_raw()

Callers 2

test_repo_packFunction · 0.85
test_pack_with_delegateFunction · 0.85

Calls 2

setup_second_repoFunction · 0.85
packMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…