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

Unified Diff: sdk/lib/_internal/pub/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/pub_generated/lib/src/sdk.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/sdk.dart
diff --git a/sdk/lib/_internal/pub/lib/src/sdk.dart b/sdk/lib/_internal/pub/lib/src/sdk.dart
index 2fe18588f599a85be0c06728b7af839b760f3293..d47cb52a7013929880183d59f1949ffe018ba49a 100644
--- a/sdk/lib/_internal/pub/lib/src/sdk.dart
+++ b/sdk/lib/_internal/pub/lib/src/sdk.dart
@@ -39,8 +39,36 @@ Version _getVersion() {
var sdkVersion = Platform.environment["_PUB_TEST_SDK_VERSION"];
if (sdkVersion != null) return new Version.parse(sdkVersion);
- // Read the "version" file.
- var revisionPath = path.join(_rootDirectory, "version");
- var version = readTextFile(revisionPath).trim();
+ if (runningFromSdk) {
nweiz 2014/09/15 23:12:25 Does this getter still return the right thing when
Bob Nystrom 2014/09/15 23:41:10 The tests don't actually get this far. They set _P
+ // Read the "version" file.
+ var version = readTextFile(path.join(_rootDirectory, "version")).trim();
+ return new Version.parse(version);
+ }
+
+ // When running from the repo, read the canonical VERSION file in tools/.
+ // This makes it possible to run pub without having built the SDK first.
nweiz 2014/09/15 23:12:25 Does this mean that our tests now depend on being
Bob Nystrom 2014/09/15 23:41:10 Our tests would have previously required that if w
+ var contents = readTextFile(path.join(repoRoot, "tools/VERSION"));
+
+ parseField(name) {
+ var pattern = new RegExp("^$name ([a-z0-9]+)", multiLine: true);
+ var match = pattern.firstMatch(contents);
+ return match[1];
+ }
+
+ var channel = parseField("CHANNEL");
+ var major = parseField("MAJOR");
+ var minor = parseField("MINOR");
+ var patch = parseField("PATCH");
+ var prerelease = parseField("PRERELEASE");
+ var prereleasePatch = parseField("PRERELEASE_PATCH");
+
+ var version = "$major.$minor.$patch";
+ if (channel == "be") {
+ // TODO(rnystrom): tools/utils.py includes the svn commit here. Should we?
nweiz 2014/09/15 23:12:26 Probably? How painful is it to get?
Bob Nystrom 2014/09/15 23:41:10 It's actually pretty hairy. 60 lines of Python tha
+ version += "-edge";
+ } else if (channel == "dev") {
+ version += "-dev.$prerelease.$prereleasePatch";
+ }
+
return new Version.parse(version);
}
« no previous file with comments | « no previous file | sdk/lib/_internal/pub_generated/lib/src/sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698