Add Bazel version scheme - #43
Open
andrew wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new bazel versioning scheme to the vers library, implementing Bazel module version ordering so consumers can correctly validate, normalize, compare, range-match, and select highest satisfying Bazel versions.
Changes:
- Introduces the
bazelscheme and wires it into scheme-aware comparison (CompareWithScheme) and normalization/validation paths. - Adds Bazel-specific parsing/comparison logic (including BCR
.bcr.Nreleases and prerelease/build handling). - Adds public API helpers and tests covering Bazel validation, normalization, classification, ranges, and highest-version selection.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| version.go | Registers the bazel scheme and routes comparison through compareBazel. |
| vers.go | Documents bazel in ParseNative and adds scheme-aware stable/prerelease helpers. |
| range.go | Prevents Bazel ranges from matching invalid candidate versions. |
| parser.go | Rejects invalid Bazel constraint versions during constraint parsing. |
| normalization.go | Adds Bazel scheme validation and normalization (dropping build metadata). |
| constraint.go | Preserves v prefix for Bazel constraints (like Go). |
| bazel.go | Implements Bazel version parsing, normalization, and ordering. |
| bazel_test.go | Adds end-to-end tests for Bazel behavior via the public API. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+149
to
+156
| func classifyVersionWithScheme(version, scheme string) (bool, bool) { | ||
| if scheme == schemeBazel { | ||
| parsed, ok := parseBazelVersion(version) | ||
| return ok && version != "", len(parsed.prerelease) != 0 | ||
| } | ||
| parsed, err := ParseVersion(version) | ||
| return err == nil, err == nil && parsed.IsPrerelease() | ||
| } |
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.
Add an implementation-defined
bazelversion scheme based on Bazel module version ordering. The scheme handles alphanumeric release identifiers, arbitrary release segment counts, BCR.bcr.Nreleases, classification, validation, normalization, ranges, and highest-version selection. Generic version comparison stays unchanged, and registry consumers remain responsible for yanked versions. It supports the version selection needed by ecosyste-ms/packages#1810 and git-pkgs/enrichment#65.