Skip to content

Commit 3b9143a

Browse files
committed
fix: ensure versions are sorted by numerical value instead of name
1 parent c6eaf61 commit 3b9143a

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

libraries/management/commands/import_library_version_website_adoc.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,29 @@ def command(release: str, new: bool, min_version: str):
3333
frozen snapshot, matching release import). A repo without the file is left
3434
untouched.
3535
"""
36+
# Order/compare on the numeric version_array so boost-1.100.0 > boost-1.71.0
37+
# (plain name ordering is lexicographic and breaks once minor/patch hits 100).
38+
min_version_parts = [int(part) for part in min_version.split(".")]
3639
version_qs = (
3740
Version.objects.with_partials()
3841
.active()
39-
.filter(name__gte=f"boost-{min_version}")
42+
.with_version_split()
43+
.filter(version_array__gte=min_version_parts)
44+
)
45+
most_recent = (
46+
version_qs.filter(beta=False, full_release=True)
47+
.order_by("-version_array")
48+
.first()
4049
)
41-
most_recent = version_qs.most_recent()
4250

4351
if release:
44-
versions = list(version_qs.filter(name__icontains=release).order_by("-name"))
52+
versions = list(
53+
version_qs.filter(name__icontains=release).order_by("-version_array")
54+
)
4555
elif new:
4656
versions = [most_recent] if most_recent else []
4757
else:
48-
versions = list(version_qs.order_by("-name"))
58+
versions = list(version_qs.order_by("-version_array"))
4959

5060
for version in versions:
5161
ref = "develop" if version == most_recent else version.name

0 commit comments

Comments
 (0)