Index: utils/pub/sdk.dart |
diff --git a/utils/pub/sdk.dart b/utils/pub/sdk.dart |
index f8db76c173ca4c1a0dc2090b8ae178d5c9ccd560..0365aab30e398ec9fb52a8065c57aac624116b75 100644 |
--- a/utils/pub/sdk.dart |
+++ b/utils/pub/sdk.dart |
@@ -11,6 +11,11 @@ import '../../pkg/path/lib/path.dart' as path; |
import 'log.dart' as log; |
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 { |
// If the environment variable was provided, use it. This is mainly used for |
@@ -30,9 +35,23 @@ String get rootDirectory { |
/// Gets the SDK's revision number formatted to be a semantic version. |
Version version = _getVersion(); |
-/// Determine the SDK revision number. |
+/// Determine the SDK's version number. |
Version _getVersion() { |
- var revisionPath = path.join(rootDirectory, "revision"); |
- var revision = new File(revisionPath).readAsStringSync(); |
- return new Version.parse("0.0.0-r.${revision.trim()}"); |
+ var revisionPath = path.join(rootDirectory, "version"); |
+ var version = new File(revisionPath).readAsStringSync().trim(); |
+ |
+ // 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: $revision"); |
+ } |
+ |
+ var build = match[4]; |
+ if (match[5].length > 0) build = '$build.${match[5]}'; |
+ |
+ return new Version( |
+ int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), |
+ build: build); |
} |