Chromium Code Reviews| 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); |
| } |