fix: Improve version comparison to handle prereleases #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enhanced CompareVersions to correctly handle prerelease tags, ensuring prerelease versions are considered less than stable releases and comparing prerelease tags alphabetically. Added comprehensive test cases to verify correct behavior for various prerelease and stable version scenarios.
Pull Request Checklist
mainbranch of tmpo.Closes #63
Description
This pull request improves the version comparison logic in the update checker by adding proper handling for prerelease versions and extending the test coverage to verify these cases. The new logic ensures that prerelease versions (like
1.0.0-rc.1) are correctly considered less than their corresponding stable releases, and that different prerelease tags are compared appropriately.Version comparison improvements:
CompareVersionsininternal/update/checker.goto split out prerelease tags, compare core versions numerically, and handle prerelease vs. stable comparisons according to semantic versioning rules.splitPrereleaseandcompareCoreVersionshelper functions to support the new comparison logic.Test coverage enhancements:
internal/update/checker_test.goto verify correct handling of prerelease vs. stable versions, alphabetical ordering of prerelease tags, and cases with version prefixes.