fix(version): tolerate prerelease suffixes in next-env-version calc#420
Merged
Conversation
The next-env-version calc parsed nextEnvVersion with the strict semver parser, which only accepts an -rc.N suffix. A stray v0.6.0-dryrun.13 value recorded as the latest aborted the whole calculation with "parsing next env version: invalid version format", which blocked a real release until the dryrun tags were pruned by hand. Discovery-side tag lookups already skip such exercise tags, but the calc path did not. Add ParseBase, which extracts the numeric core of a version and discards any pre-release suffix, and use it for nextEnvVersion. Only the base major.minor.patch feeds the calculation, so dropping the suffix is correct and cannot change the result for well-formed inputs. Closes #410 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.
What
Closes #410. The orchestrate next-env-version calc (
internal/versionCalculateNext then Parse) aborted with "invalid version format" when nextEnvVersion carried a-dryrun.Nsuffix. This broke the real v0.6.0 release; the only unblock was a manual tag prune.Root cause (deeper than #382)
#382 filtered the git-tag discovery path (GetLatest* via IsValidVersionTag). But nextEnvVersion also originates from
state.Version(orchestrator.go:383) and the no-env currentDevVersion, neither of which discovery filtering touches. A dry-run vector persists a dryrun version into state, and the next real release reads it as nextEnvVersion and aborts.Fix
Add
ParseBase, which extracts the numeric core (prefix plus major.minor.patch) and discards any prerelease suffix (-rc.N, -dryrun.N, -beta.1), erroring only when the core is not a valid triple. CalculateNext uses ParseBase for nextEnvVersion. This is inert for well-formed inputs because the calc consumes only the numeric core via BaseVersion(); the existing v1.4.0-rc.2.hotfix.1 test still passes.Tests (TDD)
TestParseBase (9 cases incl. dryrun, opaque, reject-garbage) and TestCalculateNext_NextEnvHoldsDryrunVersion (dry-run-then-release computes from base, no abort). Red before, green after. 2303 tests pass; golangci-lint clean.
Pairs with #388 (dryrun-tag sweeper, merged): the sweeper reduces accumulation, this makes the calc robust regardless.