Add Composer and Pub version support - #34
Open
andrew wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class Composer and Pub support to VERS native parsing and scheme-aware comparison/normalization, expanding ParseNative to understand these ecosystems’ constraint syntaxes and version ordering rules.
Changes:
- Introduces
composerandpubschemes with scheme-specific comparison, validation, and normalization. - Adds Composer constraint parsing (OR/AND, caret/tilde/wildcards/hyphens, stability flags, aliases) and Pub constraint parsing (any, caret, comparator intersections, Pub build ordering adjustments).
- Updates README and adds round-trip/unit tests for Composer/Pub parsing, comparison, and VERS output.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| version.go | Adds composer/pub schemes and wires scheme-specific compare functions. |
| vers.go | Documents new supported schemes in ParseNative docs. |
| README.md | Adds usage examples and scheme table entries for Composer and Pub. |
| parser.go | Routes ParseNative to Composer/Pub parsers; includes schemes in version normalization. |
| normalization.go | Adds scheme-aware validation/normalization hooks for Composer/Pub. |
| composer_pub.go | Implements Composer and Pub parsing/validation/normalization/comparison logic. |
| composer_pub_test.go | Adds tests for Composer/Pub parsing behavior, comparisons, normalization, and VERS round-trips. |
Suppressed comments (1)
composer_pub_test.go:208
- Expected VERS output for Pub caret ^0.0.3 uses an upper bound of <0.1.0-0, but Pub caret semantics for 0.0.z are patch-only, so the upper bound should be <0.0.4-0.
{constraint: "^0.0.3", scheme: schemePub, want: "vers:pub/>=0.0.3|<0.1.0-0"},
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+564
to
+580
| // parsePubCaretRange expands Pub's compatible-with operator. Pub treats all | ||
| // pre-1.0 releases in the same minor series as compatible. | ||
| func parsePubCaretRange(version string) (*Range, error) { | ||
| parsed, ok := parseSemverValue(version) | ||
| if !ok { | ||
| return nil, fmt.Errorf("invalid pub caret version: %s", version) | ||
| } | ||
| var upper string | ||
| if cmpNumStr(parsed.core[0], "0") == 0 { | ||
| upper = "0." + incNumStr(parsed.core[1]) + ".0-0" | ||
| } else { | ||
| upper = incNumStr(parsed.core[0]) + ".0.0-0" | ||
| } | ||
| return rangeWithScheme(NewRange([]Interval{ | ||
| NewInterval(version, upper, true, false), | ||
| }), schemePub), nil | ||
| } |
| {name: "caret excludes next major prerelease", constraint: "^1.2.3", version: "2.0.0-alpha", want: false}, | ||
| {name: "caret zero includes compatible patch", constraint: "^0.1.2", version: "0.1.9", want: true}, | ||
| {name: "caret zero excludes next minor", constraint: "^0.1.2", version: "0.2.0", want: false}, | ||
| {name: "caret zero zero includes later patch", constraint: "^0.0.3", version: "0.0.9", want: true}, |
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.
Adds native Composer and Pub constraint parsing to ParseNative, with scheme-aware validation, normalization, and version comparison.
Composer support includes caret, tilde, wildcard and hyphen ranges, AND/OR constraints, aliases, stability flags, and Composer’s prerelease boundary rules. It also preserves OR branches containing aliases and accepts shorthand stability suffixes.
Pub support includes any, exact versions, comparator intersections, caret ranges, Pub build ordering, pre-1.0 compatibility rules, and exclusive prerelease upper bounds. README examples and VERS round-trip coverage are included.