fix: refine stability precedence to support standard prerelease sorting#6
Conversation
|
@joaopapereira Please review this follow-up change for #5 |
1 similar comment
|
@joaopapereira Please review this follow-up change for #5 |
v4/semver.go
Outdated
| if strings.Contains(sl, "rc") { | ||
| return true | ||
| } | ||
| return strings.Contains(sl, "-") && (strings.Contains(sl, "alpha") || strings.Contains(sl, "beta")) |
There was a problem hiding this comment.
-
we are only checking for '-' for alpha only, not for beta or rc . We have to check for '-' as pre-requisite for all the pre release labels.
-
why are we restricting to check only rc , alpha, beta ? there can be other labels (pre etc) which can exist? we can do string comparison to evaluate them?
There was a problem hiding this comment.
Updated. Logic now generically uses hyphens to detect stability label.
| {"0.0.1-pre.1", "0.0.1-rc.0", -1, "Vendir: pre < rc alphabetically"}, | ||
|
|
||
| // 5. Standard SemVer: Numeric segments are always less than alphanumeric ones | ||
| {"1.0.0-alpha.1", "1.0.0-alpha.beta", -1, "Standard: numeric < alphanumeric"}, |
There was a problem hiding this comment.
this is the comparison for alphanumeric vs alpha numeric .
There was a problem hiding this comment.
Corrected. Updated the description to clarify this compares a numeric segment (1) vs an alphanumeric segment (beta) per SemVer precedence.
v4/semver_test.go
Outdated
| {"1.0.0-alpha.1", "1.0.0-alpha.beta", -1, "Standard: numeric < alphanumeric"}, | ||
|
|
||
| // 6. Stability Check: Ensure alpha/beta without hyphens follow standard rules | ||
| {"1.0.0-beta", "1.0.0-rc", -1, "Standard: beta < rc alphabetically"}, |
There was a problem hiding this comment.
Updated Description. The separator hyphen is not part of the segment itself
Signed-off-by: Sameer <sameer.khan@broadcom.com>
1c0319b to
ab3899f
Compare
Refinement of Metadata Precedence Logic
This follow-up PR adjusts the build metadata comparison logic to ensure stability-aware precedence (GA > RC) only applies when comparing numeric segments to alphanumeric ones.
Verified Improvements:
Natural Sorting: vmware.10-fips now correctly ranks higher than vmware.9-fips.
Stability: 3.4.0+v1.33 (Stable) now correctly ranks higher than 3.4.0+v1.33-rc.2.
Compatibility: Standard pre-release ordering (e.g., 0.0.1-pre.1 < 0.0.1-rc.0) is preserved, fixing a regression found in vendir.
Validation :
All 38+ existing unit tests, alongside new edge-case coverage Passed ✅
Validation with Vendir Test :
Tests Passed ✅