Skip to content

Commit 753277a

Browse files
committed
Adjust rules for canonical interface names
Tweak the string-splitting to more closely match the intent of versions found in tooling, specifically: * Document that build metadata (`+foo` in `0.0.1+foo`) is always split out and not part of the canonical name. * Don't split out pre-release information since pre-release versions are incompatible with all other versions. This additionally matches preexisting merging behavior in `wit-component` as discovered in bytecodealliance/wasm-tools#2622
1 parent 4acb0de commit 753277a

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

design/mvp/Explainer.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,15 +2883,23 @@ type checking already required).
28832883

28842884
Any `valid semver` (as used in WIT) can be canonicalized by splitting it into
28852885
two parts - the `canonversion` prefix and the remaining `semversuffix`. Using
2886-
the `<major>.<minor>.<patch>` syntax of [Semantic Versioning 2.0], the split
2887-
point is chosen as follows:
2888-
2889-
- if `major` > 0, split immediately after `major`
2886+
the `<major>.<minor>.<patch>(-<pre>)(+<build>)` syntax of [Semantic Versioning
2887+
2.0], the split point is chosen as follows:
2888+
2889+
- build metadata, if present, is always part of the `semversuffix`
2890+
- `0.0.1+sha.5114f85` &rarr; `0.0.1` / `+sha.5114f85`
2891+
- if the version has a pre-release label, then the version itself is not split
2892+
- `0.0.1-alpha` &rarr; `0.0.1-alpha` / nothing
2893+
- `0.0.1-alpha+sha.5114f85` &rarr; `0.0.1-alpha` / `+sha.5114f85`
2894+
- otherwise if `major` > 0, split immediately after `major`
28902895
- `1.2.3` &rarr; `1` / `.2.3`
2896+
- `1.2.3+sha.5114f85` &rarr; `1` / `.2.3+sha.5114f85`
28912897
- otherwise if `minor` > 0, split immediately after `minor`
2892-
- `0.2.6-rc.1` &rarr; `0.2` / `.6-rc.1`
2893-
- otherwise, split immediately after `patch`
2894-
- `0.0.1-alpha` &rarr; `0.0.1` / `-alpha`
2898+
- `0.2.6` &rarr; `0.2` / `.6`
2899+
- `0.2.6+sha.5114f85` &rarr; `0.2` / `.6+sha.5114f85`
2900+
- otherwise, the version is already canonical
2901+
- `0.0.1` &rarr; `0.0.1`
2902+
- `0.0.1+sha.5114f85` &rarr; `0.0.1` / `+sha.5114f85`
28952903

28962904
When a version is canonicalized, any `semversuffix` that was split off of the
28972905
version should be preserved in the `versionsuffix` field of any resulting

0 commit comments

Comments
 (0)