Project

Profile

Help

Issue #8714

Collection highest_version includes pre-releases

Added by fao89 about 1 month ago. Updated about 1 month ago.

Status:
NEW
Priority:
Normal
Assignee:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:

Description

Under /v3/collections/// highest_version.version includes pre-releases, for example "version": "2.2.8-pre1". The expectation likely is that this should not include pre-releases.

The list of all versions, /v3/collections///versions/ includes pre-releases and this is expected.

History

#1 Updated by fao89 about 1 month ago

In [1]: import semantic_version

In [2]: versions = [ "3.0.0-alpha", "2.5.8", "2.0.0-alpha", "2.0.1-alpha", "1.5.0"]

In [3]: sorted(versions,key=lambda obj: semantic_version.Version(obj), reverse=True)
Out[3]: ['3.0.0-alpha', '2.5.8', '2.0.1-alpha', '2.0.0-alpha', '1.5.0']

In [4]: filtered_versions = list(filter(lambda v: not semantic_version.Version(v).prerelease, versions))

In [5]: highest = sorted(filtered_versions, key=lambda obj: semantic_version.Version(obj), reverse=True)[0] if filtered_versions else sorted(versions,key=lambda obj: semantic_version.Version(obj), reverse=True)[0]

In [6]: highest
Out[6]: '2.5.8'

Affected code:

  1. v3: https://github.com/pulp/pulp_ansible/blob/master/pulp_ansible/app/galaxy/v3/serializers.py#L67-L73
  2. v2: https://github.com/pulp/pulp_ansible/blob/master/pulp_ansible/app/galaxy/serializers.py#L104-L108
  3. v2: https://github.com/pulp/pulp_ansible/blob/master/pulp_ansible/app/tasks/collections.py#L302-L323

Please register to edit this issue

Also available in: Atom PDF