Loading
Fix ordering and hashing of version suffixes in Gitlab::VersionInfo
What does this MR do and why?
Fixes two suffix-handling defects in Gitlab::VersionInfo:
- Mixed string/integer suffix parts now sort deterministically instead of returning
niland causingsortormaxto raise. Words sort before numbers, matchingGem::Version; previously defined ordering is unchanged. - Versions with equivalent parsed suffixes, such as
1.0.1-rc1and1.0.1-rc01, now have matching hashes, fixing Hash lookups anduniq.
Cached version objects remain readable across upgrades and rollbacks. Rolling back restores the old comparison and hashing behavior.
Found while maintaining gitlab-mcp-server.
References
Closes #635968 (closed)
Screenshots or screen recordings
Not applicable: no UI change.
How to set up and validate locally
-
Open the Rails console on this branch with
bundle exec rails console. -
Verify mixed suffix ordering and equivalent-version deduplication:
rc = Gitlab::VersionInfo.parse('16.0.0-rc1', parse_suffix: true) numbered = Gitlab::VersionInfo.parse('16.0.0-1', parse_suffix: true) [numbered, rc].sort.map(&:to_s) # => ["16.0.0-rc1", "16.0.0-1"] equivalent = Gitlab::VersionInfo.parse('16.0.0-rc01', parse_suffix: true) [rc.eql?(equivalent), rc.hash == equivalent.hash, [rc, equivalent].uniq.size] # => [true, true, 1] { rc => :found }[equivalent] # => :found
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Pedro Pombeiro