diff --git a/swh/loader/package/deposit/loader.py b/swh/loader/package/deposit/loader.py
--- a/swh/loader/package/deposit/loader.py
+++ b/swh/loader/package/deposit/loader.py
@@ -57,6 +57,7 @@
"""The collection in the deposit; see SWORD specification."""
author = attr.ib(type=Person)
committer = attr.ib(type=Person)
+ release_notes = attr.ib(type=Optional[str])
@classmethod
def from_metadata(
@@ -88,6 +89,7 @@
collection=depo["collection"],
author=parse_author(depo["author"]),
committer=parse_author(depo["committer"]),
+ release_notes=depo["release_notes"],
raw_info=raw_info,
directory_extrinsic_metadata=[
RawExtrinsicMetadataCore(
@@ -196,12 +198,18 @@
self, p_info: DepositPackageInfo, uncompressed_path: str, directory: Sha1Git,
) -> Optional[Release]:
message = (
- f"{p_info.client}: Deposit {p_info.id} in collection {p_info.collection}\n"
- ).encode("utf-8")
+ f"{p_info.client}: Deposit {p_info.id} in collection {p_info.collection}"
+ )
+
+ if p_info.release_notes:
+ message += "\n\n" + p_info.release_notes
+
+ if not message.endswith("\n"):
+ message += "\n"
return Release(
name=p_info.version.encode(),
- message=message,
+ message=message.encode(),
author=p_info.author,
date=TimestampWithTimezone.from_dict(p_info.author_date),
target=directory,
diff --git a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/1_private_999_meta b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/1_private_999_meta
new file mode 120000
--- /dev/null
+++ b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/1_private_999_meta
@@ -0,0 +1 @@
+hello_2.13.json
\ No newline at end of file
diff --git a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/1_private_999_raw b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/1_private_999_raw
new file mode 120000
--- /dev/null
+++ b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/1_private_999_raw
@@ -0,0 +1 @@
+hello-2.10.zip
\ No newline at end of file
diff --git a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.10.json b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.10.json
--- a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.10.json
+++ b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.10.json
@@ -57,6 +57,7 @@
"offset": 0,
"negative_utc": false
},
- "revision_parents": []
+ "revision_parents": [],
+ "release_notes": null
}
}
diff --git a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.11.json b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.11.json
--- a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.11.json
+++ b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.11.json
@@ -60,6 +60,7 @@
"offset": 0,
"negative_utc": false
},
- "revision_parents": []
+ "revision_parents": [],
+ "release_notes": null
}
}
diff --git a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.12.json b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.12.json
--- a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.12.json
+++ b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.12.json
@@ -60,6 +60,7 @@
"offset": 0,
"negative_utc": false
},
- "revision_parents": []
+ "revision_parents": [],
+ "release_notes": null
}
}
diff --git a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.12.json b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.13.json
copy from swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.12.json
copy to swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.13.json
--- a/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.12.json
+++ b/swh/loader/package/deposit/tests/data/https_deposit.softwareheritage.org/hello_2.13.json
@@ -4,7 +4,7 @@
"type": "deposit"
},
"metadata_raw": ["some-external-idhttps://hal-test.archives-ouvertes.fr/some-external-id2017-10-07T15:17:08Zsome awesome authoranother oneno one",
-"someone"
+"someone\nThis release adds this and that."
],
"metadata_dict": {
"author": [
@@ -31,7 +31,7 @@
}
},
"deposit": {
- "id": 888,
+ "id": 999,
"client": "hal",
"collection": "hal",
"author": {
@@ -60,6 +60,7 @@
"offset": 0,
"negative_utc": false
},
- "revision_parents": []
+ "revision_parents": [],
+ "release_notes": "This release adds this and that."
}
}
diff --git a/swh/loader/package/deposit/tests/test_deposit.py b/swh/loader/package/deposit/tests/test_deposit.py
--- a/swh/loader/package/deposit/tests/test_deposit.py
+++ b/swh/loader/package/deposit/tests/test_deposit.py
@@ -500,3 +500,64 @@
type="deposit",
snapshot=hash_to_bytes(expected_snapshot_id),
)
+
+
+def test_deposit_loading_ok_release_notes(
+ swh_storage, deposit_client, requests_mock_datadir
+):
+ url = "https://hal-test.archives-ouvertes.fr/some-external-id"
+ deposit_id = 999
+ loader = DepositLoader(
+ swh_storage, url, deposit_id, deposit_client, default_filename="archive.zip"
+ )
+
+ actual_load_status = loader.load()
+ expected_snapshot_id = "a307acffb7c29bebb3daf1bcb680bb3f452890a8"
+ assert actual_load_status == {
+ "status": "eventful",
+ "snapshot_id": expected_snapshot_id,
+ }
+
+ assert_last_visit_matches(
+ loader.storage,
+ url,
+ status="full",
+ type="deposit",
+ snapshot=hash_to_bytes(expected_snapshot_id),
+ )
+
+ release_id_hex = "f5e8ec02ede57edbe061afa7fc2a07bb7d14a700"
+ release_id = hash_to_bytes(release_id_hex)
+
+ expected_snapshot = Snapshot(
+ id=hash_to_bytes(expected_snapshot_id),
+ branches={
+ b"HEAD": SnapshotBranch(target=release_id, target_type=TargetType.RELEASE,),
+ },
+ )
+ check_snapshot(expected_snapshot, storage=loader.storage)
+
+ release = loader.storage.release_get([release_id])[0]
+ date = TimestampWithTimezone(
+ timestamp=Timestamp(seconds=1507389428, microseconds=0),
+ offset=0,
+ negative_utc=False,
+ )
+ person = Person(
+ fullname=b"Software Heritage",
+ name=b"Software Heritage",
+ email=b"robot@softwareheritage.org",
+ )
+ assert release == Release(
+ id=release_id,
+ name=b"HEAD",
+ message=(
+ b"hal: Deposit 999 in collection hal\n\nThis release adds this and that.\n"
+ ),
+ author=person,
+ date=date,
+ target_type=ModelObjectType.DIRECTORY,
+ target=b"\xfd-\xf1-\xc5SL\x1d\xa1\xe9\x18\x0b\x91Q\x02\xfbo`\x1d\x19",
+ synthetic=True,
+ metadata=None,
+ )