Skip to content

Preserve opt-in prefix semantics in comparisons#2

Closed
Sagar Verma (ssagarverma) wants to merge 2 commits into
BESTSELLER:masterfrom
ssagarverma:followup/prefix-context-tests
Closed

Preserve opt-in prefix semantics in comparisons#2
Sagar Verma (ssagarverma) wants to merge 2 commits into
BESTSELLER:masterfrom
ssagarverma:followup/prefix-context-tests

Conversation

@ssagarverma
Copy link
Copy Markdown

Summary

Follow-up to hashicorp#79.

This stacks on top of BESTSELLER/go-version:master, which is the current head branch for the upstream PR.

Changes

  • preserve default NewVersion behavior so arbitrary prefixed versions still fail without opt-in
  • keep prefixed parsing behind WithPrefix
  • store explicit prefix context on Version
  • add CompareStrict to reject cross-prefix comparisons when both sides were created with explicit prefixes
  • split legacy comparison tests from opt-in prefix comparison tests
  • add focused tests for strict cross-prefix mismatch and accessor behavior with prefixed versions

Why

PR hashicorp#79 adds opt-in custom prefix parsing. This follow-up keeps the existing non-opt-in behavior strict while making cross-prefix matching explicit and test-covered.

Validation

  • go test ./...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant