fix: sort versions semantically (ascending order)#2
Merged
Conversation
Versions were returned in the order they appeared in the HTML from ftp.postgresql.org, which was reverse lexicographic order. This caused issues like 9.6.9 appearing before 9.6.24 and version 10.x appearing after 9.x. Added semantic version comparison that: - Parses version strings into numeric parts - Compares parts numerically (not lexicographically) - Sorts in ascending order (oldest first, newest last)
2 tasks
jdx
added a commit
to jdx/mise
that referenced
this pull request
Jan 18, 2026
## Summary
- Adds a new `semver` Lua module that vfox plugins can use for semantic
version comparison and sorting
- Eliminates the need for each plugin to implement their own version
sorting logic
## API
- `semver.compare(v1, v2)` - Returns -1, 0, or 1
- `semver.parse(version)` - Returns table of numeric parts
- `semver.sort(versions)` - Sorts string array ascending
- `semver.sort_by(items, field)` - Sorts table array by version field
## Example Usage
```lua
local semver = require("semver")
-- Method 1: Use in custom sort
table.sort(result, function(a, b)
return semver.compare(a.version, b.version) < 0
end)
-- Method 2: Use sort_by helper
result = semver.sort_by(result, "version")
```
## Test Plan
- [x] Unit tests for `parse_version`, `compare_versions`
- [x] Lua integration test
## Related
- vfox-postgres fix:
mise-plugins/vfox-postgres#2
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds a built-in `semver` Lua module and integrates it into the plugin
runtime.
>
> - New `lua_mod/semver.rs` exports `compare`, `parse`, `sort`, and
`sort_by` for semantic version handling; includes unit and Lua
integration tests
> - Registers `semver` in `lua_mod/mod.rs` and loads it in `plugin.rs`
so `require("semver")` is available to plugins
> - Updates `docs/plugin-lua-modules.md` with `semver` usage and
examples
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e97711a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Changes
Before
After
🤖 Generated with Claude Code