btcctl: preserve semantic version separators - #2596
Open
pucedoteth wants to merge 2 commits into
Open
Conversation
The root version.go gained periods in semanticAlphabet in 65db493, but cmd/btcctl carries its own copy of that code and was left behind, so btcctl still collapses beta.rc1 into betarc1. appBuild is settable at build time via '-ldflags "-X main.appBuild ..."' and SemVer build metadata is dot-separated, so a build stamped with exp.sha.5114f85 reports expsha5114f85. Mirror the upstream test, adding a build metadata case.
Every case asserted normalizeVerString(x) == x, so an identity function -- that is, dropping the filter entirely -- satisfied the whole table. Make it table-driven with explicit in/want and add a case whose input contains a character outside the semantic alphabet, so the test fails if the filter stops filtering. Verified by neutralising the alphabet check in place: the new case fails with got "beta!rc1", want "betarc1", while the dotted cases still fail if '.' is removed from the alphabet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Author
|
Pushed a test-only follow-up. The original table asserted Verified by neutralising the alphabet check in place ( |
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.
65db493 ("version: preserve semantic version separators", #2578) added periods to
semanticAlphabetin the rootversion.go, because SemVer separates pre-release identifiers with periods and the old filter silently collapsedbeta.rc1intobetarc1.cmd/btcctlcarries its own near-identical copy of that file, and it was not updated. The two now disagree:So
btcctlstill drops the separator. The upstream test, run unchanged against the btcctl copy, fails:This is reachable rather than latent.
normalizeVerStringis applied toappBuild, which the comment above it documents as settable at build time:SemVer build metadata is dot-separated (
exp.sha.5114f85is an example from the spec itself), so a btcctl built with-ldflags "-X main.appBuild=exp.sha.5114f85"reports0.23.1-beta+expsha5114f85— the dots stripped and the metadata no longer round-trips.btcdbuilt the same way reports it correctly.The change is the one-character fix from 65db493 applied to the btcctl copy, plus that commit's test mirrored into
cmd/btcctl, with a build metadata case added for theappBuildpath.go build ./...,go test ./cmd/...,gofmtandgo vetare all clean.I left the stale
appMinor/appPatchin the btcctl copy alone (0.23.1 there vs 0.26.2 at the root) since bumping those is a release decision, not part of this fix.Disclosure: written with AI assistance; the analysis, fix and test were verified locally.