From e8fa9a45b81eff9686cc94696e856ab8b2fc91c3 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz <vlorentz@softwareheritage.org> Date: Thu, 14 Sep 2023 15:07:51 +0200 Subject: [PATCH] to_disk: Represent revisions as empty directories instead of symlinks The symlink representation is slightly ambiguous, so not necessarily very useful. Additionally, it made directory-flat bundles differ from a non-recursive 'git clone' checkout, which confuses Guix and potentially other tools. We may revisit this in the future, eg. by adding a dotfile in the directory or metadata at the root. --- swh/vault/tests/test_cookers.py | 4 ++-- swh/vault/to_disk.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/swh/vault/tests/test_cookers.py b/swh/vault/tests/test_cookers.py index 227b3f6..042b831 100644 --- a/swh/vault/tests/test_cookers.py +++ b/swh/vault/tests/test_cookers.py @@ -580,8 +580,8 @@ class TestDirectoryCooker: with cook_extract_directory_dircooker( swh_storage, dir.swhid(), fsck=False ) as p: - assert (p / "submodule").is_symlink() - assert os.readlink(str(p / "submodule")) == target_rev + assert (p / "submodule").is_dir() + assert list((p / "submodule").iterdir()) == [] class RepoFixtures: diff --git a/swh/vault/to_disk.py b/swh/vault/to_disk.py index b2b1650..5971c51 100644 --- a/swh/vault/to_disk.py +++ b/swh/vault/to_disk.py @@ -133,8 +133,7 @@ class DirectoryBuilder: identifier.""" for file_data in revs_data: path = os.path.join(self.root, file_data["path"]) - target = hashutil.hash_to_bytehex(file_data["target"]) - self._create_file(path, target, mode=DentryPerms.symlink) + os.makedirs(path) def _create_file( self, path: bytes, content: bytes, mode: int = DentryPerms.content -- GitLab