diff --git a/NEWS b/NEWS index 5be495267..43ced4d67 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ * Deprecate ``dulwich.objects.parse_commit``. + * Fix fetching into MemoryRepo. (Jelmer Vernooij, #1157) + 0.21.3 2023-02-17 * Add support for ``worktreeconfig`` extension. diff --git a/dulwich/object_store.py b/dulwich/object_store.py index 8888696eb..4446c7593 100644 --- a/dulwich/object_store.py +++ b/dulwich/object_store.py @@ -1048,6 +1048,16 @@ def abort(): return f, commit, abort + def add_pack_data(self, count: int, unpacked_objects: Iterator[UnpackedObject], progress=None) -> None: + """Add pack data to this object store. + + Args: + count: Number of items to add + pack_data: Iterator over pack data tuples + """ + for unpacked_object in unpacked_objects: + self.add_object(unpacked_object.sha_file()) + def add_thin_pack(self, read_all, read_some, progress=None): """Add a new thin pack to this object store. diff --git a/dulwich/tests/test_repository.py b/dulwich/tests/test_repository.py index 7fa631a18..bcb827796 100644 --- a/dulwich/tests/test_repository.py +++ b/dulwich/tests/test_repository.py @@ -124,6 +124,12 @@ def test_set_description(self): r.set_description(description) self.assertEqual(description, r.get_description()) + def test_pull_into(self): + r = MemoryRepo.init_bare([], {}) + repo = open_repo("a.git") + self.addCleanup(tear_down_repo, repo) + repo.fetch(r) + class RepositoryRootTests(TestCase): def mkdtemp(self):