Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cookers/git_bare.py
Show First 20 Lines • Show All 336 Lines • ▼ Show 20 Lines | class GitBareCooker(BaseVaultCooker): | ||||
def write_content(self, obj_id: Sha1Git, content: bytes) -> None: | def write_content(self, obj_id: Sha1Git, content: bytes) -> None: | ||||
header = identifiers.git_object_header("blob", len(content)) | header = identifiers.git_object_header("blob", len(content)) | ||||
self.write_object(obj_id, header + content) | self.write_object(obj_id, header + content) | ||||
def _expect_mismatched_object_error(self, obj_id): | def _expect_mismatched_object_error(self, obj_id): | ||||
obj_id_hex = hash_to_hex(obj_id) | obj_id_hex = hash_to_hex(obj_id) | ||||
obj_path = self._obj_relative_path(obj_id) | obj_path = self._obj_relative_path(obj_id) | ||||
# For Git < 2.21: | |||||
self._expected_fsck_errors.add( | self._expected_fsck_errors.add( | ||||
f"error: sha1 mismatch for ./{obj_path} (expected {obj_id_hex})" | f"error: sha1 mismatch for ./{obj_path} (expected {obj_id_hex})" | ||||
) | ) | ||||
# For Git >= 2.21: | |||||
self._expected_fsck_errors.add( | |||||
f"error: hash mismatch for ./{obj_path} (expected {obj_id_hex})" | |||||
) | |||||
self._expected_fsck_errors.add( | self._expected_fsck_errors.add( | ||||
f"error: {obj_id_hex}: object corrupt or missing: ./{obj_path}" | f"error: {obj_id_hex}: object corrupt or missing: ./{obj_path}" | ||||
) | ) | ||||
self._expected_fsck_errors.add(f"missing blob {obj_id_hex}") | self._expected_fsck_errors.add(f"missing blob {obj_id_hex}") |