Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123234
D8974.id32329.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
D8974.id32329.diff
View Options
diff --git a/swh/loader/package/conda/loader.py b/swh/loader/package/conda/loader.py
--- a/swh/loader/package/conda/loader.py
+++ b/swh/loader/package/conda/loader.py
@@ -29,7 +29,11 @@
"""Archive (tar.gz) file name"""
version = attr.ib(type=str)
- """Complete version and distribution name. Ex: 'linux-64/0.1.1-py37'
+ """Complete version and distribution name used as branch name. Ex: 'linux-64/0.1.1-py37'
+ """
+
+ release_version = attr.ib(type=str)
+ """Version number used as release name. Ex: '0.1.1-py37-linux-64'
"""
last_modified: Optional[datetime] = attr.ib()
@@ -102,7 +106,11 @@
["0.1.1", "0.10.2"]
"""
versions = list(self.artifacts.keys())
- versions.sort(key=parse_version)
+ versions.sort(
+ key=lambda version_key: parse_version(
+ version_key.split("/", 1)[1].split("-", 1)[0]
+ )
+ )
return versions
def get_default_version(self) -> str:
@@ -135,11 +143,14 @@
if data.get("date"):
last_modified = iso8601.parse_date(data["date"])
+ arch, version_and_build = data["version"].split("/", 1)
+
p_info = CondaPackageInfo(
name=pkgname,
filename=filename,
url=url,
version=version,
+ release_version=f"{version_and_build}-{arch}",
last_modified=last_modified,
checksums=data["checksums"],
)
@@ -170,7 +181,7 @@
)
return Release(
- name=p_info.version.encode(),
+ name=p_info.release_version.encode(),
author=author,
date=last_modified,
message=message.encode(),
diff --git a/swh/loader/package/conda/tests/test_conda.py b/swh/loader/package/conda/tests/test_conda.py
--- a/swh/loader/package/conda/tests/test_conda.py
+++ b/swh/loader/package/conda/tests/test_conda.py
@@ -5,7 +5,7 @@
from swh.loader.package.conda.loader import CondaLoader
from swh.loader.tests import assert_last_visit_matches, check_snapshot, get_stats
-from swh.model.hashutil import hash_to_bytes
+from swh.model.hashutil import hash_to_bytes, hash_to_hex
from swh.model.model import (
ObjectType,
Person,
@@ -72,19 +72,39 @@
assert load_status["status"] == "eventful"
assert load_status["snapshot_id"] is not None
- expected_snapshot_id = "9c20bedf9af54ef7b3937fe4675f9f17b9331b7b"
+ first_release = Release(
+ name=b"0.11.1-py36h9f0ad1d_1-linux-64",
+ message=b"Synthetic release for Conda source package lifetimes version"
+ b" linux-64/0.11.1-py36h9f0ad1d_1\n",
+ target=hash_to_bytes("0c63e5f909e481d8e5832bac8abbd089bca42993"),
+ target_type=ObjectType.DIRECTORY,
+ synthetic=True,
+ author=Person(
+ fullname=b"CamDavidsonPilon", name=b"CamDavidsonPilon", email=None
+ ),
+ date=TimestampWithTimezone.from_iso8601("2020-07-06T12:19:36.425000+00:00"),
+ )
- assert expected_snapshot_id == load_status["snapshot_id"]
+ # This one have empty author and date
+ second_release = Release(
+ name=b"0.11.1-py36hc560c46_1-linux-64",
+ message=b"Synthetic release for Conda source package lifetimes version"
+ b" linux-64/0.11.1-py36hc560c46_1\n",
+ target=hash_to_bytes("45ca406aeb31f51836a8593b619ab216403ce489"),
+ target_type=ObjectType.DIRECTORY,
+ synthetic=True,
+ author=Person(fullname=b"", name=None, email=None),
+ date=None,
+ )
expected_snapshot = Snapshot(
- id=hash_to_bytes(load_status["snapshot_id"]),
branches={
b"releases/linux-64/0.11.1-py36h9f0ad1d_1": SnapshotBranch(
- target=hash_to_bytes("9848f61b501801799025d632221833a0f988dca2"),
+ target=first_release.id,
target_type=TargetType.RELEASE,
),
b"releases/linux-64/0.11.1-py36hc560c46_1": SnapshotBranch(
- target=hash_to_bytes("fad38f867db9311504a4c340f2b32dcdffa46e27"),
+ target=second_release.id,
target_type=TargetType.RELEASE,
),
b"HEAD": SnapshotBranch(
@@ -94,6 +114,8 @@
},
)
+ assert hash_to_hex(expected_snapshot.id) == load_status["snapshot_id"]
+
check_snapshot(expected_snapshot, swh_storage)
stats = get_stats(swh_storage)
@@ -108,45 +130,6 @@
"snapshot": 1,
} == stats
- assert swh_storage.release_get(
- [hash_to_bytes("9848f61b501801799025d632221833a0f988dca2")]
- )[0] == Release(
- name=b"linux-64/0.11.1-py36h9f0ad1d_1",
- message=b"Synthetic release for Conda source package lifetimes version"
- b" linux-64/0.11.1-py36h9f0ad1d_1\n",
- target=hash_to_bytes("0c63e5f909e481d8e5832bac8abbd089bca42993"),
- target_type=ObjectType.DIRECTORY,
- synthetic=True,
- author=Person(
- fullname=b"CamDavidsonPilon", name=b"CamDavidsonPilon", email=None
- ),
- date=TimestampWithTimezone.from_iso8601("2020-07-06T12:19:36.425000+00:00"),
- id=hash_to_bytes("9848f61b501801799025d632221833a0f988dca2"),
- )
-
- assert_last_visit_matches(
- swh_storage,
- url=ORIGINS[0]["url"],
- status="full",
- type="conda",
- snapshot=hash_to_bytes(load_status["snapshot_id"]),
- )
-
- # This one have empty author and date
- assert swh_storage.release_get(
- [hash_to_bytes("fad38f867db9311504a4c340f2b32dcdffa46e27")]
- )[0] == Release(
- name=b"linux-64/0.11.1-py36hc560c46_1",
- message=b"Synthetic release for Conda source package lifetimes version"
- b" linux-64/0.11.1-py36hc560c46_1\n",
- target=hash_to_bytes("45ca406aeb31f51836a8593b619ab216403ce489"),
- target_type=ObjectType.DIRECTORY,
- synthetic=True,
- author=Person(fullname=b"", name=None, email=None),
- date=None,
- id=hash_to_bytes("fad38f867db9311504a4c340f2b32dcdffa46e27"),
- )
-
assert_last_visit_matches(
swh_storage,
url=ORIGINS[0]["url"],
diff --git a/swh/loader/package/rpm/loader.py b/swh/loader/package/rpm/loader.py
--- a/swh/loader/package/rpm/loader.py
+++ b/swh/loader/package/rpm/loader.py
@@ -91,7 +91,14 @@
def get_versions(self) -> Sequence[str]:
"""Returns the keys of the packages input (e.g. fedora34/everything/1.18.0-5, etc...)"""
- return list(sorted(self.packages, key=parse_version))
+ return list(
+ sorted(
+ self.packages,
+ key=lambda version_key: parse_version(
+ self.packages[version_key]["version"]
+ ),
+ )
+ )
def get_default_version(self) -> str:
"""Get the latest release version of a rpm package"""
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 18, 4:16 AM (1 d, 1 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216974
Attached To
D8974: conda, rpm: Fix package versions sorting
Event Timeline
Log In to Comment