Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: sdk/lib/_internal/pub_generated/lib/src/sdk.dart

Issue 572053002: Parse the repo's version file when running from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library pub.sdk; 1 library pub.sdk;
2 import 'dart:io'; 2 import 'dart:io';
3 import 'package:path/path.dart' as path; 3 import 'package:path/path.dart' as path;
4 import 'io.dart'; 4 import 'io.dart';
5 import 'version.dart'; 5 import 'version.dart';
6 final String rootDirectory = 6 final String rootDirectory =
7 runningFromSdk ? _rootDirectory : path.join(repoRoot, "sdk"); 7 runningFromSdk ? _rootDirectory : path.join(repoRoot, "sdk");
8 final String _rootDirectory = path.dirname(path.dirname(Platform.executable)); 8 final String _rootDirectory = path.dirname(path.dirname(Platform.executable));
9 Version version = _getVersion(); 9 Version version = _getVersion();
10 Version _getVersion() { 10 Version _getVersion() {
11 var sdkVersion = Platform.environment["_PUB_TEST_SDK_VERSION"]; 11 var sdkVersion = Platform.environment["_PUB_TEST_SDK_VERSION"];
12 if (sdkVersion != null) return new Version.parse(sdkVersion); 12 if (sdkVersion != null) return new Version.parse(sdkVersion);
13 var revisionPath = path.join(_rootDirectory, "version"); 13 if (runningFromSdk) {
14 var version = readTextFile(revisionPath).trim(); 14 var version = readTextFile(path.join(_rootDirectory, "version")).trim();
15 return new Version.parse(version);
16 }
17 var contents = readTextFile(path.join(repoRoot, "tools/VERSION"));
18 parseField(name) {
19 var pattern = new RegExp("^$name ([a-z0-9]+)", multiLine: true);
20 var match = pattern.firstMatch(contents);
21 return match[1];
22 }
23 var channel = parseField("CHANNEL");
24 var major = parseField("MAJOR");
25 var minor = parseField("MINOR");
26 var patch = parseField("PATCH");
27 var prerelease = parseField("PRERELEASE");
28 var prereleasePatch = parseField("PRERELEASE_PATCH");
29 var version = "$major.$minor.$patch";
30 if (channel == "be") {
31 version += "-edge";
32 } else if (channel == "dev") {
33 version += "-dev.$prerelease.$prereleasePatch";
34 }
15 return new Version.parse(version); 35 return new Version.parse(version);
16 } 36 }
OLDNEW
« sdk/lib/_internal/pub/lib/src/sdk.dart ('K') | « sdk/lib/_internal/pub/lib/src/sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698