feat(version): add semantic version tag selection #135
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!135
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/semver-tag-selection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implement semantic version tag selection in
pkg/version(stdlib only, no new dependencies):Parse(tag)(#38) — parses strictv<major>.<minor>.<patch>tags into aSemVer. Rejects tags without thevprefix, non-numeric components, pre-release (-rc1) and build (+meta) suffixes, and malformed versions.Highest(tags)(#40) — returns the tag with the greatest version by numeric comparison (major → minor → patch), sov10.0.0beatsv9.9.9. Ignores non-matching tags; reportsfalsewhen nothing matches.SemVer.greater; no lexicographic string sort.SemVer.String()returns the canonicalvX.Y.Zform.Tests: table-driven coverage for parse validity (valid, missing prefix, pre-release/build suffixes, non-numeric, empty), highest selection (numeric ordering, tag filtering, empty/no-match, single element, pre-release ignored), and
String.Why
Phase 3 task #41 — the tag-selection logic the webhook receiver (#72) uses to pick the production version after a push, and rollback (#90) uses to reselect after a tag deletion.
Testing
go build ./...go vet ./...go test -race ./pkg/version/— 3 test functions / 24 subtests passgofmt -l ./cmd ./internal ./pkgcleangolangci-lint run— 0 issuesBreaking Changes
None.
Notes
vX.Y.Zonly); can be added later if preview/release-candidate tags are wanted for production.Closes #38
Closes #39
Closes #40
Closes #41
Review Summary
Verified locally on the PR head (
9538542):go build,go vet,gofmt(incl../pkg),golangci-lint runall clean; all 3 test functions / 24 subtests pass with-race.Clean, dependency-free implementation.
Parsecorrectly rejects missing prefix, wrong component counts (includingv1.2.3.4viaSplitN+Atoifailure), pre-release/build suffixes, non-numeric and negative components, and overflow.Highestuses numeric (not lexicographic) ordering, filters non-matching tags, and reportsfalseon no match. Table-driven tests are thorough.Extra edge cases I probed locally:
v01.2.3accepted,v1.2.3./v1.2/V1.2.3rejected, integer overflow rejected — all sensible.No blocking issues.
Non-blocking observation:
v01.2.3parses to 1.2.3), so two distinct tags could compare equal —Highestreturns whichever comes first, andSemVer.String()normalizes tov1.2.3whileTagpreserves the original. Harmless for deployment selection, but strict semver disallows leading zeros if that ever matters.Approving.