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

Fix sorting of versions containing hyphens #221

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

PHPirates
Copy link
Contributor

Pull Request Details

  • Fix compareTo for versions that have equal major, minor and patch versions and both contain a hyphen

Description

Assume that if all major, minor and patch versions are the same, a version with a hyphen is older than a version without one.

Related Issue

Fix #171

Motivation and Context

When two versions e.g. 0.9.5-alpha.3 and 0.9.5-alpha.4 both contained a hyphen, the compareTo always returned -1 no matter which was left or right.
This violates the compareTo contract, causing issues like #171.

How Has This Been Tested

If I put the full changelog from here in the test then I reproduce #171. Unfortunately I did not manage to create a minimal test for this, but with this change for me the issue is fixed.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the README.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@PHPirates
Copy link
Contributor Author

@hsz Could you have a look?

@hsz hsz added this to the next milestone Jul 4, 2024
@hsz
Copy link
Member

hsz commented Jul 4, 2024

Sorry for the late reply! Looks good, thank you!

@hsz hsz merged commit 16710e6 into JetBrains:main Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comparison method violates its general contract!
2 participants