| Index: utils/pub/version.dart
|
| diff --git a/utils/pub/version.dart b/utils/pub/version.dart
|
| index 50174cc40cb6f676821ea71c7f9778d1746b341e..346b372141f0064c1d6e1a6160843233acca0695 100644
|
| --- a/utils/pub/version.dart
|
| +++ b/utils/pub/version.dart
|
| @@ -74,6 +74,20 @@ class Version implements Comparable, VersionConstraint {
|
| }
|
| }
|
|
|
| + /// Returns the primary version out of a list of candidates. This is the
|
| + /// highest-numbered stable (non-prerelease) version. If there are no stable
|
| + /// versions, it's just the highest-numbered version.
|
| + static Version primary(List<Version> versions) {
|
| + var primary;
|
| + for (var version in versions) {
|
| + if (primary == null || (!version.isPreRelease && primary.isPreRelease) ||
|
| + (version.isPreRelease == primary.isPreRelease && version > primary)) {
|
| + primary = version;
|
| + }
|
| + }
|
| + return primary;
|
| + }
|
| +
|
| bool operator ==(other) {
|
| if (other is! Version) return false;
|
| return compareTo(other) == 0;
|
| @@ -84,8 +98,12 @@ class Version implements Comparable, VersionConstraint {
|
| bool operator <=(Version other) => compareTo(other) <= 0;
|
| bool operator >=(Version other) => compareTo(other) >= 0;
|
|
|
| + bool get isAny => false;
|
| bool get isEmpty => false;
|
|
|
| + /// Whether or not this is a pre-release version.
|
| + bool get isPreRelease => preRelease != null;
|
| +
|
| /** Tests if [other] matches this version exactly. */
|
| bool allows(Version other) => this == other;
|
|
|
| @@ -252,6 +270,9 @@ abstract class VersionConstraint {
|
| */
|
| bool get isEmpty;
|
|
|
| + /// Returns `true` if this constraint allows all versions.
|
| + bool get isAny;
|
| +
|
| /**
|
| * Returns `true` if this constraint allows [version].
|
| */
|
| @@ -321,6 +342,8 @@ class VersionRange implements VersionConstraint {
|
|
|
| bool get isEmpty => false;
|
|
|
| + bool get isAny => !includeMin && !includeMax;
|
| +
|
| /** Tests if [other] matches falls within this version range. */
|
| bool allows(Version other) {
|
| if (min != null && other < min) return false;
|
| @@ -415,6 +438,7 @@ class _EmptyVersion implements VersionConstraint {
|
| const _EmptyVersion();
|
|
|
| bool get isEmpty => true;
|
| + bool get isAny => false;
|
| bool allows(Version other) => false;
|
| VersionConstraint intersect(VersionConstraint other) => this;
|
| String toString() => '<empty>';
|
|
|