feat: support rc-based hotfix version segment - #101
Merged
Merged
Conversation
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.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.
Problem
The version model only understands
vX.Y.ZandvX.Y.Z-rc.N. A version carrying an in-flight hotfix segment (vX.Y.Z-rc.N.hotfix.M) failsversion.Parse. Because the orchestrator reads the next environment's version intoCalculator.CalculateNext, an environment holding a hotfix version would break orchestration of the environment below it. Hotfix-aware version handling is a prerequisite for the rest of the hotfix capability.Fix
Extend
internal/version:Hotfix inttoVersion(sentinel-1, matchingPreRelease).vX.Y.Z-rc.N.hotfix.Mshape via a nested optional regex group, so ahotfixsegment is only valid after anrcsegment.vX.Y.Z-hotfix.M, missing/non-numeric hotfix numbers, and the wrong separator are rejected.String()round-trips the dotted form.Base()/BaseVersion()/StripRCstrip the hotfix segment (the published semver isvX.Y.Z).WithHotfix(m)andNextHotfix()helpers (first hotfix ishotfix.1).Compare()gives strict precedence:rc.2 < rc.2.hotfix.1 < rc.2.hotfix.2 < rc.3.CalculateNextcomputes from the rc base and ignores any.hotfix.Mon the next env version, so a diverged environment cannot break orchestration of the one below it.Per the locked design, the dotted segment applies only to rc-based (still-in-flight) versions; a published-base hotfix is a normal patch bump handled elsewhere, so no
vX.Y.Z-hotfix.Mshape is added here.Verification
go build ./...: successgo test ./internal/version/... ./internal/promote/... ./internal/orchestrate/...: 207 passedgolangci-lint run ./internal/version/... ./internal/promote/...: no issuesNew tests:
TestParse_HotfixSegment,TestParse_RejectsMalformedHotfix,TestVersion_Ordering_HotfixBetweenRCs,TestCalculateNext_NextEnvHoldsHotfixVersion,TestStripRC_HotfixVersion, and promote-sideTestStripRCSuffix_HotfixVersion. Existing non-hotfix tests are unchanged in intent (expected-value literals gained the-1hotfix sentinel only).