| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * This file contains functionality for getting dart version numbers using | 6 * This file contains functionality for getting dart version numbers using |
| 7 * our standard version construction method. Systems that does not include this | 7 * our standard version construction method. Systems that does not include this |
| 8 * file should emulate the structure for revision numbers that we have here. | 8 * file should emulate the structure for revision numbers that we have here. |
| 9 * | 9 * |
| 10 * The version number of a dart build is constructed as follows: | 10 * The version number of a dart build is constructed as follows: |
| 11 * 1. The major, minor, build and patch numbers are extracted from the VERSION | 11 * 1. The major, minor, build and patch numbers are extracted from the VERSION |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 if (!wasCompletedWithError) { | 55 if (!wasCompletedWithError) { |
| 56 c.completeError(msg); | 56 c.completeError(msg); |
| 57 wasCompletedWithError = true; | 57 wasCompletedWithError = true; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 f.exists().then((existed) { | 60 f.exists().then((existed) { |
| 61 if (!existed) { | 61 if (!existed) { |
| 62 completeError("No VERSION file"); | 62 completeError("No VERSION file"); |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 StringInputStream input = new StringInputStream(f.openInputStream()); | 65 Stream<String> stream = |
| 66 input.onLine = () { | 66 f.openRead().transform(new StringDecoder()) |
| 67 var line = input.readLine().trim(); | 67 .transform(new LineTransformer()); |
| 68 stream.listen((String line) { |
| 68 if (line == null) { | 69 if (line == null) { |
| 69 completeError( | 70 completeError( |
| 70 "VERSION input file seems to be in the wrong format"); | 71 "VERSION input file seems to be in the wrong format"); |
| 71 return; | 72 return; |
| 72 } | 73 } |
| 73 var values = line.split(" "); | 74 var values = line.split(" "); |
| 74 if (values.length != 2) { | 75 if (values.length != 2) { |
| 75 completeError( | 76 completeError( |
| 76 "VERSION input file seems to be in the wrong format"); | 77 "VERSION input file seems to be in the wrong format"); |
| 77 return; | 78 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 94 BUILD = number; | 95 BUILD = number; |
| 95 break; | 96 break; |
| 96 case "PATCH": | 97 case "PATCH": |
| 97 PATCH = number; | 98 PATCH = number; |
| 98 break; | 99 break; |
| 99 default: | 100 default: |
| 100 completeError("Wrong format in VERSION file, line does not " | 101 completeError("Wrong format in VERSION file, line does not " |
| 101 "contain one of {MAJOR, MINOR, BUILD, PATCH}"); | 102 "contain one of {MAJOR, MINOR, BUILD, PATCH}"); |
| 102 return; | 103 return; |
| 103 } | 104 } |
| 104 }; | 105 }, |
| 105 input.onClosed = () { | 106 onDone: () { |
| 106 // Only complete if we did not already complete with a failure. | 107 // Only complete if we did not already complete with a failure. |
| 107 if (!wasCompletedWithError) { | 108 if (!wasCompletedWithError) { |
| 108 getRevision().then((revision) { | 109 getRevision().then((revision) { |
| 109 REVISION = revision; | 110 REVISION = revision; |
| 110 USERNAME = getUserName(); | 111 USERNAME = getUserName(); |
| 111 var userNameString = ""; | 112 var userNameString = ""; |
| 112 if (USERNAME != '') userNameString = "_$USERNAME"; | 113 if (USERNAME != '') userNameString = "_$USERNAME"; |
| 113 var revisionString = ""; | 114 var revisionString = ""; |
| 114 if (revision != 0) revisionString = "_r$revision"; | 115 if (revision != 0) revisionString = "_r$revision"; |
| 115 c.complete( | 116 c.complete( |
| 116 "$MAJOR.$MINOR.$BUILD.$PATCH$revisionString$userNameString"); | 117 "$MAJOR.$MINOR.$BUILD.$PATCH$revisionString$userNameString"); |
| 117 return; | 118 return; |
| 118 }); | 119 }); |
| 119 } | 120 } |
| 120 }; | 121 }); |
| 121 }); | 122 }); |
| 122 return c.future; | 123 return c.future; |
| 123 } | 124 } |
| 124 | 125 |
| 125 String getExecutableSuffix() { | 126 String getExecutableSuffix() { |
| 126 if (Platform.operatingSystem == 'windows') { | 127 if (Platform.operatingSystem == 'windows') { |
| 127 return '.bat'; | 128 return '.bat'; |
| 128 } | 129 } |
| 129 return ''; | 130 return ''; |
| 130 } | 131 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 static RepositoryType guessType() { | 217 static RepositoryType guessType() { |
| 217 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; | 218 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; |
| 218 if (new Directory(".git").existsSync()) return RepositoryType.GIT; | 219 if (new Directory(".git").existsSync()) return RepositoryType.GIT; |
| 219 return RepositoryType.UNKNOWN; | 220 return RepositoryType.UNKNOWN; |
| 220 } | 221 } |
| 221 | 222 |
| 222 String toString() => name; | 223 String toString() => name; |
| 223 | 224 |
| 224 final String name; | 225 final String name; |
| 225 } | 226 } |
| OLD | NEW |