Issue #8714
closed
Collection highest_version includes pre-releases
Status:
CLOSED - DUPLICATE
Description
Ticket moved to GitHub: "pulp/pulp_ansible/723":https://github.com/pulp/pulp_ansible/issues/723
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.
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:
- v3: https://github.com/pulp/pulp_ansible/blob/master/pulp_ansible/app/galaxy/v3/serializers.py#L67-L73
- v2: https://github.com/pulp/pulp_ansible/blob/master/pulp_ansible/app/galaxy/serializers.py#L104-L108
- v2: https://github.com/pulp/pulp_ansible/blob/master/pulp_ansible/app/tasks/collections.py#L302-L323
- Sprint/Milestone set to 1.0.0 - Candidates
- Description updated (diff)
- Status changed from NEW to CLOSED - DUPLICATE
Also available in: Atom
PDF