Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semantic_version says pre-release versions can be higher than release versions #1391

Closed
jctanner opened this issue Mar 9, 2023 · 1 comment · Fixed by #1392
Closed

semantic_version says pre-release versions can be higher than release versions #1391

jctanner opened this issue Mar 9, 2023 · 1 comment · Fixed by #1392

Comments

@jctanner
Copy link
Contributor

jctanner commented Mar 9, 2023

Version
main

Describe the bug
semantic_version says "2.0.1-rc1" is greater than "1.0.1", which is perhaps true per the spec but I think we collectively think otherwise.

To Reproduce


versions = ['1.0.0', '2.0.0', '3.0.0-rc.1']
versions = [Version(x) for x in versions]
print(max(versions))

Expected behavior
Pre-release versions should only get marked as is_highest when no stable releases exist.

jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 9, 2023
…ns exist.

fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
@mdellweg
Copy link
Member

mdellweg commented Mar 15, 2023

I did some experiment, and i cannot confirm the original claim that

"1.0.1-rc1" is greater than "1.0.1"

I can however see, that in case we have "2.0.0" and "3.0.0-rc.1" we do not want to consider the latter as the highest_(stable_)version. Can we not search the highest stable version and fall back to the highest of all if there was none?

In [1]: from semver import compare  # This is not what we are using. Just for comparison...

In [2]: from semantic_version import Version

In [3]: compare("1.2.3-rc", "1.2.2")
Out[3]: 1

In [4]: compare("1.2.3-rc", "1.2.3")
Out[4]: -1

In [5]: Version("1.2.3-rc") > Version("1.2.2")
Out[5]: True

In [6]: Version("1.2.3-rc") > Version("1.2.3")
Out[6]: False

In [7]: Version("1.2.3-rc.1") > Version("1.2.3")
Out[7]: False

In [8]: Version("1.2.3-rc.1") > Version("1.2.2")
Out[8]: True

jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 15, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 15, 2023
…re-releases exist.

fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 17, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 17, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 17, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 17, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 20, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 20, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner/pulp_ansible that referenced this issue Mar 20, 2023
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
gerrod3 pushed a commit that referenced this issue Mar 20, 2023
…n exists. (#1392)

* Do not use pre-release versions as is_highest unless no stable versions exist.

fixes: #1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
mdellweg pushed a commit that referenced this issue Sep 25, 2024
…n exists. (#1392)

* Do not use pre-release versions as is_highest unless no stable versions exist.

fixes: #1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
(cherry picked from commit 8ad72ba)
mdellweg pushed a commit that referenced this issue Sep 25, 2024
…n exists. (#1392)

* Do not use pre-release versions as is_highest unless no stable versions exist.

fixes: #1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
(cherry picked from commit 8ad72ba)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants