Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9312066
D6196.id22442.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D6196.id22442.diff
View Options
diff --git a/swh/vault/cookers/git_bare.py b/swh/vault/cookers/git_bare.py
--- a/swh/vault/cookers/git_bare.py
+++ b/swh/vault/cookers/git_bare.py
@@ -515,14 +515,15 @@
self.write_object(obj_id, git_object)
# Add children to the stack
- entry_loaders: Dict[str, List[Sha1Git]] = {
+ entry_loaders: Dict[str, Optional[List[Sha1Git]]] = {
"file": self._cnt_stack,
"dir": self._dir_stack,
- "rev": self._rev_stack,
+ "rev": None, # Do not include submodule targets (rejected by git-fsck)
}
for entry in directory["entries"]:
stack = entry_loaders[entry["type"]]
- self._push(stack, [entry["target"]])
+ if stack is not None:
+ self._push(stack, [entry["target"]])
def load_contents(self, obj_ids: List[Sha1Git]) -> None:
# TODO: add support of filtered objects, somehow?
diff --git a/swh/vault/tests/test_cookers.py b/swh/vault/tests/test_cookers.py
--- a/swh/vault/tests/test_cookers.py
+++ b/swh/vault/tests/test_cookers.py
@@ -972,20 +972,33 @@
with cook_extract_revision(loader.storage, swhid, fsck=False) as (ert, p):
self.check_revision_null_fields(ert, p, swhid)
- def test_revision_submodule(self, swh_storage, cook_extract_revision):
- target_rev = "0e8a3ad980ec179856012b7eecf4327e99cd44cd"
-
+ @pytest.mark.parametrize("ingest_target_revision", [False, True])
+ def test_revision_submodule(
+ self, swh_storage, cook_extract_revision, ingest_target_revision
+ ):
date = TimestampWithTimezone.from_datetime(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
)
+ target_rev = Revision(
+ message=b"target_rev",
+ author=Person.from_fullname(b"me <test@example.org>"),
+ date=date,
+ committer=Person.from_fullname(b"me <test@example.org>"),
+ committer_date=date,
+ parents=(),
+ type=RevisionType.GIT,
+ directory=bytes.fromhex("3333333333333333333333333333333333333333"),
+ metadata={},
+ synthetic=True,
+ )
+ if ingest_target_revision:
+ swh_storage.revision_add([target_rev])
+
dir = Directory(
entries=(
DirectoryEntry(
- name=b"submodule",
- type="rev",
- target=hashutil.hash_to_bytes(target_rev),
- perms=0o160000,
+ name=b"submodule", type="rev", target=target_rev.id, perms=0o160000,
),
),
)
@@ -1007,7 +1020,7 @@
with cook_extract_revision(swh_storage, rev.swhid()) as (ert, p):
ert.checkout(b"HEAD")
- pattern = b"160000 submodule\x00%s" % hashutil.hash_to_bytes(target_rev)
+ pattern = b"160000 submodule\x00%s" % target_rev.id
tree = ert.repo[b"HEAD"].tree
assert pattern in ert.repo[tree].as_raw_string()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 2, 10:41 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218355
Attached To
D6196: git_bare: Don't cook submodule targets
Event Timeline
Log In to Comment