| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 Stream<String> stream = | 65 StringInputStream input = new StringInputStream(f.openInputStream()); |
| 66 f.openRead().transform(new StringDecoder()) | 66 input.onLine = () { |
| 67 .transform(new LineTransformer()); | 67 var line = input.readLine().trim(); |
| 68 stream.listen((String line) { | |
| 69 if (line == null) { | 68 if (line == null) { |
| 70 completeError( | 69 completeError( |
| 71 "VERSION input file seems to be in the wrong format"); | 70 "VERSION input file seems to be in the wrong format"); |
| 72 return; | 71 return; |
| 73 } | 72 } |
| 74 var values = line.split(" "); | 73 var values = line.split(" "); |
| 75 if (values.length != 2) { | 74 if (values.length != 2) { |
| 76 completeError( | 75 completeError( |
| 77 "VERSION input file seems to be in the wrong format"); | 76 "VERSION input file seems to be in the wrong format"); |
| 78 return; | 77 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 95 BUILD = number; | 94 BUILD = number; |
| 96 break; | 95 break; |
| 97 case "PATCH": | 96 case "PATCH": |
| 98 PATCH = number; | 97 PATCH = number; |
| 99 break; | 98 break; |
| 100 default: | 99 default: |
| 101 completeError("Wrong format in VERSION file, line does not " | 100 completeError("Wrong format in VERSION file, line does not " |
| 102 "contain one of {MAJOR, MINOR, BUILD, PATCH}"); | 101 "contain one of {MAJOR, MINOR, BUILD, PATCH}"); |
| 103 return; | 102 return; |
| 104 } | 103 } |
| 105 }, | 104 }; |
| 106 onDone: () { | 105 input.onClosed = () { |
| 107 // Only complete if we did not already complete with a failure. | 106 // Only complete if we did not already complete with a failure. |
| 108 if (!wasCompletedWithError) { | 107 if (!wasCompletedWithError) { |
| 109 getRevision().then((revision) { | 108 getRevision().then((revision) { |
| 110 REVISION = revision; | 109 REVISION = revision; |
| 111 USERNAME = getUserName(); | 110 USERNAME = getUserName(); |
| 112 var userNameString = ""; | 111 var userNameString = ""; |
| 113 if (USERNAME != '') userNameString = "_$USERNAME"; | 112 if (USERNAME != '') userNameString = "_$USERNAME"; |
| 114 var revisionString = ""; | 113 var revisionString = ""; |
| 115 if (revision != 0) revisionString = "_r$revision"; | 114 if (revision != 0) revisionString = "_r$revision"; |
| 116 c.complete( | 115 c.complete( |
| 117 "$MAJOR.$MINOR.$BUILD.$PATCH$revisionString$userNameString"); | 116 "$MAJOR.$MINOR.$BUILD.$PATCH$revisionString$userNameString"); |
| 118 return; | 117 return; |
| 119 }); | 118 }); |
| 120 } | 119 } |
| 121 }); | 120 }; |
| 122 }); | 121 }); |
| 123 return c.future; | 122 return c.future; |
| 124 } | 123 } |
| 125 | 124 |
| 126 String getExecutableSuffix() { | 125 String getExecutableSuffix() { |
| 127 if (Platform.operatingSystem == 'windows') { | 126 if (Platform.operatingSystem == 'windows') { |
| 128 return '.bat'; | 127 return '.bat'; |
| 129 } | 128 } |
| 130 return ''; | 129 return ''; |
| 131 } | 130 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 static RepositoryType guessType() { | 216 static RepositoryType guessType() { |
| 218 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; | 217 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; |
| 219 if (new Directory(".git").existsSync()) return RepositoryType.GIT; | 218 if (new Directory(".git").existsSync()) return RepositoryType.GIT; |
| 220 return RepositoryType.UNKNOWN; | 219 return RepositoryType.UNKNOWN; |
| 221 } | 220 } |
| 222 | 221 |
| 223 String toString() => name; | 222 String toString() => name; |
| 224 | 223 |
| 225 final String name; | 224 final String name; |
| 226 } | 225 } |
| OLD | NEW |