diff --git a/swh/deposit/api/private/deposit_read.py b/swh/deposit/api/private/deposit_read.py --- a/swh/deposit/api/private/deposit_read.py +++ b/swh/deposit/api/private/deposit_read.py @@ -174,50 +174,36 @@ # Read information metadata data = {"origin": {"type": "deposit", "url": deposit.origin_url,}} - # revision - - fullname = deposit.client.username - author_committer = SWH_PERSON - # metadata provider self.provider["provider_name"] = deposit.client.last_name self.provider["provider_url"] = deposit.client.provider_url - revision_type = "tar" - revision_msg = "%s: Deposit %s in collection %s" % ( - fullname, - deposit.id, - deposit.collection.name, - ) - author_date, commit_date = self._normalize_dates(deposit, metadata) - data["revision"] = { - "synthetic": True, - "date": author_date, - "committer_date": commit_date, - "author": author_committer, - "committer": author_committer, - "type": revision_type, - "message": revision_msg, - "metadata": metadata, - } - if deposit.parent: swh_persistent_id = deposit.parent.swh_id persistent_identifier = identifiers.parse_persistent_identifier( swh_persistent_id ) parent_revision = persistent_identifier.object_id + parents = [parent_revision] + else: + parents = [] - data["revision"]["parents"] = [parent_revision] - - data["branch_name"] = "master" data["origin_metadata"] = { "provider": self.provider, "tool": self.tool, "metadata": metadata, } + data["deposit"] = { + "id": deposit.id, + "fullname": deposit.client.username, + "collection": deposit.collection.name, + "author": SWH_PERSON, + "revision_parents": parents, + "author_date": author_date, + "committer_date": commit_date, + } return data diff --git a/swh/deposit/tests/api/test_deposit_private_read_metadata.py b/swh/deposit/tests/api/test_deposit_private_read_metadata.py --- a/swh/deposit/tests/api/test_deposit_private_read_metadata.py +++ b/swh/deposit/tests/api/test_deposit_private_read_metadata.py @@ -63,7 +63,6 @@ data = response.json() expected_meta = { - "branch_name": "master", "origin": { "type": "deposit", "url": "https://hal-test.archives-ouvertes.fr/some-external-id", @@ -88,29 +87,22 @@ "version": "0.0.1", }, }, - "revision": { + "deposit": { "author": SWH_PERSON, - "committer": SWH_PERSON, "committer_date": { "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, - "date": { + "author_date": { "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, - "message": "test: Deposit %s in collection test" % deposit.id, - "metadata": { - "@xmlns": ["http://www.w3.org/2005/Atom"], - "author": ["some awesome author", "another one", "no one"], - "codemeta:dateCreated": "2017-10-07T15:17:08Z", - "external_identifier": "some-external-id", - "url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa - }, - "synthetic": True, - "type": "tar", + "fullname": "test", + "id": deposit.id, + "collection": "test", + "revision_parents": [], }, } @@ -146,7 +138,6 @@ data = response.json() expected_meta = { - "branch_name": "master", "origin": { "type": "deposit", "url": "https://hal-test.archives-ouvertes.fr/some-external-id", @@ -171,30 +162,22 @@ "version": "0.0.1", }, }, - "revision": { + "deposit": { "author": SWH_PERSON, - "committer": SWH_PERSON, "committer_date": { "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, - "date": { + "author_date": { "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, - "message": "test: Deposit %s in collection test" % deposit.id, - "metadata": { - "@xmlns": ["http://www.w3.org/2005/Atom"], - "author": ["some awesome author", "another one", "no one"], - "codemeta:dateCreated": "2017-10-07T15:17:08Z", - "external_identifier": "some-external-id", - "url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa - }, - "synthetic": True, - "type": "tar", - "parents": [rev_id], + "fullname": "test", + "id": deposit.id, + "collection": "test", + "revision_parents": [rev_id], }, } @@ -273,7 +256,6 @@ "url": "https://hal-test.archives-ouvertes.fr/some-external-id", } expected_meta = { - "branch_name": "master", "origin": { "type": "deposit", "url": "https://hal-test.archives-ouvertes.fr/hal-01243065", @@ -292,24 +274,22 @@ "version": "0.0.1", }, }, - "revision": { + "deposit": { "author": SWH_PERSON, - "committer": SWH_PERSON, "committer_date": { "negative_utc": False, "offset": 120, "timestamp": {"microseconds": 0, "seconds": 1493820527}, }, - "date": { + "author_date": { "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, - "message": "%s: Deposit %s in collection %s" - % (deposit_collection.name, deposit.id, deposit_collection.name), - "metadata": metadata, - "synthetic": True, - "type": "tar", + "fullname": deposit_collection.name, + "id": deposit.id, + "collection": deposit_collection.name, + "revision_parents": [], }, } assert data == expected_meta @@ -395,39 +375,32 @@ }, } - expected_revision = { + expected_deposit_info = { "author": { "email": "robot@softwareheritage.org", "fullname": "Software Heritage", "name": "Software Heritage", }, - "committer": { - "email": "robot@softwareheritage.org", - "fullname": "Software Heritage", - "name": "Software Heritage", - }, "committer_date": { "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1459900800}, }, - "date": { + "author_date": { "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1459900800}, }, - "message": "%s: Deposit %s in collection %s" - % (deposit_collection.name, deposit.id, deposit_collection.name), - "metadata": metadata, - "synthetic": True, - "type": "tar", + "fullname": deposit_collection.name, + "id": deposit.id, + "collection": deposit_collection.name, + "revision_parents": [], } expected_meta = { - "branch_name": "master", "origin": expected_origin, "origin_metadata": expected_origin_metadata, - "revision": expected_revision, + "deposit": expected_deposit_info, } assert data == expected_meta @@ -531,39 +504,32 @@ }, } - expected_revision = { + expected_deposit_info = { "author": { "email": "robot@softwareheritage.org", "fullname": "Software Heritage", "name": "Software Heritage", }, - "committer": { - "email": "robot@softwareheritage.org", - "fullname": "Software Heritage", - "name": "Software Heritage", - }, "committer_date": { "negative_utc": False, "offset": 120, "timestamp": {"microseconds": 0, "seconds": 1493820527}, }, - "date": { + "author_date": { "negative_utc": False, "offset": 120, "timestamp": {"microseconds": 0, "seconds": 1428332927}, }, - "message": "%s: Deposit %s in collection %s" - % (deposit_collection.name, deposit.id, deposit_collection.name), - "metadata": metadata, - "synthetic": True, - "type": "tar", + "fullname": deposit_collection.name, + "id": deposit.id, + "collection": deposit_collection.name, + "revision_parents": [], } expected_meta = { - "branch_name": "master", "origin": expected_origin, "origin_metadata": expected_origin_metadata, - "revision": expected_revision, + "deposit": expected_deposit_info, } assert data == expected_meta