| OLD | NEW |
| 1 Handles version numbers and version constraints in the same way that [pub][] | 1 Handles version numbers and version constraints in the same way that [pub][] |
| 2 does. The semantics here very closely follow the [Semantic Versioning][semver] | 2 does. The semantics here very closely follow the [Semantic Versioning][semver] |
| 3 spec. It differs from semver in a few corner cases: | 3 spec. It differs from semver in a few corner cases: |
| 4 | 4 |
| 5 * **Version ordering does take build suffixes into account.** This is unlike | 5 * **Version ordering does take build suffixes into account.** This is unlike |
| 6 semver 2.0.0 but like earlier versions of semver. Version `1.2.3+1` is | 6 semver 2.0.0 but like earlier versions of semver. Version `1.2.3+1` is |
| 7 considered a lower number than `1.2.3+2`. | 7 considered a lower number than `1.2.3+2`. |
| 8 | 8 |
| 9 Since a package may have published multiple versions that differ only by | 9 Since a package may have published multiple versions that differ only by |
| 10 build suffix, pub still has to pick one of them *somehow*. Semver leaves | 10 build suffix, pub still has to pick one of them *somehow*. Semver leaves |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 Versions `2.0.0` and `2.1.0` are excluded by the constraint since neither | 26 Versions `2.0.0` and `2.1.0` are excluded by the constraint since neither |
| 27 matches `<2.0.0`. However, since semver specifies that pre-release versions | 27 matches `<2.0.0`. However, since semver specifies that pre-release versions |
| 28 are lower than the non-prerelease version (i.e. `2.0.0-beta < 2.0.0`, then | 28 are lower than the non-prerelease version (i.e. `2.0.0-beta < 2.0.0`, then |
| 29 the `<2.0.0` constraint does technically allow those. | 29 the `<2.0.0` constraint does technically allow those. |
| 30 | 30 |
| 31 But that's almost never what the user wants. If their package doesn't work | 31 But that's almost never what the user wants. If their package doesn't work |
| 32 with foo `2.0.0`, it's certainly not likely to work with experimental, | 32 with foo `2.0.0`, it's certainly not likely to work with experimental, |
| 33 unstable versions of `2.0.0`'s API, which is what pre-release versions | 33 unstable versions of `2.0.0`'s API, which is what pre-release versions |
| 34 represent. | 34 represent. |
| 35 | 35 |
| 36 To handle that, `<` version ranges to not allow pre-release versions of the | 36 To handle that, `<` version ranges don't allow pre-release versions of the |
| 37 maximum unless the max is itself a pre-release. In other words, a `<2.0.0` | 37 maximum unless the max is itself a pre-release, or the min is a pre-release |
| 38 constraint will prohibit not just `2.0.0` but any pre-release of `2.0.0`. | 38 of the same version. In other words, a `<2.0.0` constraint will prohibit not |
| 39 However, `<2.0.0-beta` will exclude `2.0.0-beta` but allow `2.0.0-alpha`. | 39 just `2.0.0` but any pre-release of `2.0.0`. However, `<2.0.0-beta` will |
| 40 exclude `2.0.0-beta` but allow `2.0.0-alpha`. Likewise, `>2.0.0-alpha |
| 41 <2.0.0` will exclude `2.0.0-alpha` but allow `2.0.0-beta`. |
| 40 | 42 |
| 41 * **Pre-release versions are avoided when possible.** The above case | 43 * **Pre-release versions are avoided when possible.** The above case |
| 42 handles pre-release versions at the top of the range, but what about in | 44 handles pre-release versions at the top of the range, but what about in |
| 43 the middle? What if "foo" has these versions: | 45 the middle? What if "foo" has these versions: |
| 44 | 46 |
| 45 * `1.0.0` | 47 * `1.0.0` |
| 46 * `1.2.0-alpha` | 48 * `1.2.0-alpha` |
| 47 * `1.2.0` | 49 * `1.2.0` |
| 48 * `1.3.0-experimental` | 50 * `1.3.0-experimental` |
| 49 | 51 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 `0.0.3` -> `0.1.0` | 89 `0.0.3` -> `0.1.0` |
| 88 `0.7.2-alpha` -> `0.8.0` | 90 `0.7.2-alpha` -> `0.8.0` |
| 89 `1.2.3` -> `2.0.0` | 91 `1.2.3` -> `2.0.0` |
| 90 | 92 |
| 91 To make use of this, pub defines a "^" operator which yields a version | 93 To make use of this, pub defines a "^" operator which yields a version |
| 92 constraint greater than or equal to a given version, but less than its next | 94 constraint greater than or equal to a given version, but less than its next |
| 93 breaking one. | 95 breaking one. |
| 94 | 96 |
| 95 [pub]: http://pub.dartlang.org/ | 97 [pub]: http://pub.dartlang.org/ |
| 96 [semver]: http://semver.org/ | 98 [semver]: http://semver.org/ |
| OLD | NEW |