Skip to content

feat: support rc-based hotfix version segment - #101

Merged
joshua-temple merged 2 commits into
mainfrom
feat/hotfix-version-segment
Jun 11, 2026
Merged

joshua-temple merged 2 commits into
mainfrom
feat/hotfix-version-segment

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

The version model only understands vX.Y.Z and vX.Y.Z-rc.N. A version carrying an in-flight hotfix segment (vX.Y.Z-rc.N.hotfix.M) fails version.Parse. Because the orchestrator reads the next environment's version into Calculator.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:

  • Add Hotfix int to Version (sentinel -1, matching PreRelease).
  • Parse the new vX.Y.Z-rc.N.hotfix.M shape via a nested optional regex group, so a hotfix segment is only valid after an rc segment. vX.Y.Z-hotfix.M, missing/non-numeric hotfix numbers, and the wrong separator are rejected.
  • String() round-trips the dotted form.
  • Base()/BaseVersion()/StripRC strip the hotfix segment (the published semver is vX.Y.Z).
  • WithHotfix(m) and NextHotfix() helpers (first hotfix is hotfix.1).
  • Compare() gives strict precedence: rc.2 < rc.2.hotfix.1 < rc.2.hotfix.2 < rc.3.
  • CalculateNext computes from the rc base and ignores any .hotfix.M on 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.M shape is added here.

Verification

  • go build ./...: success
  • go test ./internal/version/... ./internal/promote/... ./internal/orchestrate/...: 207 passed
  • golangci-lint run ./internal/version/... ./internal/promote/...: no issues

New tests: TestParse_HotfixSegment, TestParse_RejectsMalformedHotfix, TestVersion_Ordering_HotfixBetweenRCs, TestCalculateNext_NextEnvHoldsHotfixVersion, TestStripRC_HotfixVersion, and promote-side TestStripRCSuffix_HotfixVersion. Existing non-hotfix tests are unchanged in intent (expected-value literals gained the -1 hotfix sentinel only).

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit 1afac02 into main Jun 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant