Skip to content

feat: add semver module for unified version handling#289

Merged
Sunrisepeak merged 1 commit into
mainfrom
feat/semver-module
May 12, 2026
Merged

feat: add semver module for unified version handling#289
Sunrisepeak merged 1 commit into
mainfrom
feat/semver-module

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

  • Add xlings::semver module with version parsing, comparison, and range matching
  • Replace ad-hoc version handling in catalog, resolver, and xvm commands
  • Fix lexicographic comparison bug (e.g. "9.0" > "15.0" was wrong)
  • Support version range expressions: ^, ~, >=, >, <, <=, *

Supported syntax

1.2.3          exact match
15             prefix range [15.0.0, 16.0.0)
^1.2.3         compatible [1.2.3, 2.0.0)
~1.2.3         patch-level [1.2.3, 1.3.0)
>=1.0.0        greater or equal
>=1.0.0 <2.0.0 combined range
1.2.*          wildcard
1.0.0-beta.1   prerelease (sorts lower than 1.0.0)

Scope

  • Replaces: catalog.cppm select_version_, resolver.cppm version selection, commands.cppm cmd_use latest sorting
  • Unchanged: xvm internal version keys (gcc-15.1.0, glibc-2.39) — these are opaque binding labels, not user-facing versions

Test plan

  • 28 unit tests (parse, compare, sort, range, select_best)
  • xlings builds successfully
  • Backward compatible: bare versions and prefix matching work as before

Add xlings::semver module with version parsing, comparison, range
matching (^, ~, >=, >, <, <=, *), and selection utilities. Replace
ad-hoc version handling in catalog, resolver, and xvm commands with
semver functions, fixing lexicographic comparison bugs (e.g. "9.0" >
"15.0") and adding support for version range expressions.

Changes:
- New src/core/semver.cppm: parse, compare, sort_desc, parse_range,
  satisfies, select_best
- catalog.cppm: select_version_ uses semver::select_best
- resolver.cppm: version selection uses semver::sort_desc
- commands.cppm: cmd_use latest uses semver::sort_desc
- 28 unit tests for parse, compare, range, select_best
- xvm internal version keys (gcc-15.1.0 etc) intentionally unchanged
@Sunrisepeak Sunrisepeak merged commit 69a517e into main May 12, 2026
3 checks passed
Sunrisepeak added a commit that referenced this pull request May 12, 2026
Includes:
- semver module for unified version handling (#289)
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.

1 participant