| Index: dart/sdk/lib/_internal/pub/lib/src/sdk.dart
|
| diff --git a/dart/sdk/lib/_internal/pub/lib/src/sdk.dart b/dart/sdk/lib/_internal/pub/lib/src/sdk.dart
|
| index bd8314b2062d891a77dd073c687324f759cabd43..c99f516a3a57077265bba483aa0854240612d470 100644
|
| --- a/dart/sdk/lib/_internal/pub/lib/src/sdk.dart
|
| +++ b/dart/sdk/lib/_internal/pub/lib/src/sdk.dart
|
| @@ -12,6 +12,11 @@ import 'package:path/path.dart' as path;
|
| import 'io.dart';
|
| import 'version.dart';
|
|
|
| +/// Matches an Eclipse-style SDK version number. This is four dotted numbers
|
| +/// (major, minor, patch, build) with an optional suffix attached to the build
|
| +/// number.
|
| +final _versionPattern = new RegExp(r'^(\d+)\.(\d+)\.(\d+)\.(\d+.*)$');
|
| +
|
| /// Gets the path to the root directory of the SDK.
|
| String get rootDirectory {
|
| // Assume the Dart executable is always coming from the SDK.
|
| @@ -24,6 +29,30 @@ String get rootDirectory {
|
| /// different SDK versions.
|
| Version version = _getVersion();
|
|
|
| +/// Is `true` if the current SDK is an unreleased bleeding edge version.
|
| +bool get isBleedingEdge {
|
| + // The live build is locked to the magical old number "0.1.2+<stuff>".
|
| + return version.major == 0 && version.minor == 1 && version.patch == 2;
|
| +}
|
| +
|
| +/// Parse an Eclipse-style version number using the SDK's versioning convention.
|
| +Version parseVersion(String version) {
|
| + // Given a version file like: 0.1.2.0_r17495
|
| + // We create a semver like: 0.1.2+0.r17495
|
| + var match = _versionPattern.firstMatch(version);
|
| + if (match == null) {
|
| + throw new FormatException("The Dart SDK's 'version' file was not in a "
|
| + "format pub could recognize. Found: $version");
|
| + }
|
| +
|
| + // Semantic versions cannot use "_".
|
| + var build = match[4].replaceAll('_', '.');
|
| +
|
| + return new Version(
|
| + int.parse(match[1]), int.parse(match[2]), int.parse(match[3]),
|
| + build: build);
|
| +}
|
| +
|
| /// Determine the SDK's version number.
|
| Version _getVersion() {
|
| // Some of the pub integration tests require an SDK version number, but the
|
| @@ -35,5 +64,5 @@ Version _getVersion() {
|
| // Read the "version" file.
|
| var revisionPath = path.join(rootDirectory, "version");
|
| var version = readTextFile(revisionPath).trim();
|
| - return new Version.parse(version);
|
| + return parseVersion(version);
|
| }
|
|
|