gradle-changelog-plugin icon indicating copy to clipboard operation
gradle-changelog-plugin copied to clipboard

Fix sorting of versions containing hyphens

Open PHPirates opened this issue 11 months ago • 1 comments

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
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [x] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

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

PHPirates avatar Mar 22 '24 19:03 PHPirates

@hsz Could you have a look?

PHPirates avatar Apr 27 '24 15:04 PHPirates

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

hsz avatar Jul 04 '24 11:07 hsz