@@ -271,29 +271,29 @@ def test_repo_discovery_uses_storage_environment(self): |
271 | 271 |
|
272 | 272 | assert osp.samefile(Repo(git_dir).common_dir, byte_common_dir) |
273 | 273 |
|
274 | | - def test_repo_discovery_preserves_object_directory(self): |
275 | | - with tempfile.TemporaryDirectory() as tdir: |
276 | | - git_dir = Path(tdir) / "git" |
277 | | - payload = b"custom object database" |
278 | | - payload_file = Path(tdir) / "payload" |
279 | | - payload_file.write_bytes(payload) |
280 | | - |
281 | | - source_repo = Repo.init(git_dir, bare=True) |
282 | | - blob_hexsha = source_repo.git.hash_object("-w", payload_file) |
283 | | - source_repo.close() |
284 | | - object_dir = Path(tdir) / "objects" |
285 | | - (git_dir / "objects").rename(object_dir) |
286 | | - |
287 | | - with cwd(tdir), mock.patch.dict(os.environ, {"GIT_DIR": "git", "GIT_OBJECT_DIRECTORY": "objects"}): |
288 | | - repo = Repo(odbt=GitDB) |
289 | | - |
290 | | - with repo: |
291 | | - assert osp.samefile(repo.odb.root_path(), object_dir) |
292 | | - assert repo.odb.has_object(bytes.fromhex(blob_hexsha)) |
293 | | - assert repo.git.cat_file("blob", blob_hexsha) == payload.decode() |
294 | | - repo.alternates = ["other/location"] |
295 | | - assert repo.alternates == ["other/location"] |
296 | | - assert (object_dir / "info" / "alternates").is_file() |
| 274 | + @with_rw_directory |
| 275 | + def test_repo_discovery_preserves_object_directory(self, tdir): |
| 276 | + git_dir = Path(tdir) / "git" |
| 277 | + payload = b"custom object database" |
| 278 | + payload_file = Path(tdir) / "payload" |
| 279 | + payload_file.write_bytes(payload) |
| 280 | + |
| 281 | + source_repo = Repo.init(git_dir, bare=True) |
| 282 | + blob_hexsha = source_repo.git.hash_object("-w", payload_file) |
| 283 | + source_repo.close() |
| 284 | + object_dir = Path(tdir) / "objects" |
| 285 | + (git_dir / "objects").rename(object_dir) |
| 286 | + |
| 287 | + with cwd(tdir), mock.patch.dict(os.environ, {"GIT_DIR": "git", "GIT_OBJECT_DIRECTORY": "objects"}): |
| 288 | + repo = Repo(odbt=GitDB) |
| 289 | + |
| 290 | + with repo: |
| 291 | + assert osp.samefile(repo.odb.root_path(), object_dir) |
| 292 | + assert repo.odb.has_object(bytes.fromhex(blob_hexsha)) |
| 293 | + assert repo.git.cat_file("blob", blob_hexsha) == payload.decode() |
| 294 | + repo.alternates = ["other/location"] |
| 295 | + assert repo.alternates == ["other/location"] |
| 296 | + assert (object_dir / "info" / "alternates").is_file() |
297 | 297 |
|
298 | 298 | @with_rw_repo("0.3.2.1") |
299 | 299 | def test_repo_creation_from_different_paths(self, rw_repo): |
|