| OLD | NEW |
| 1 // Copyright (c) 2012, 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: |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 String getExecutableSuffix() { | 115 String getExecutableSuffix() { |
| 116 if (Platform.operatingSystem == 'windows') { | 116 if (Platform.operatingSystem == 'windows') { |
| 117 return '.bat'; | 117 return '.bat'; |
| 118 } | 118 } |
| 119 return ''; | 119 return ''; |
| 120 } | 120 } |
| 121 | 121 |
| 122 int getRevisionFromSvnInfo(String info) { | 122 int getRevisionFromSvnInfo(String info) { |
| 123 if (info == null || info == '') return 0; | 123 if (info == null || info == '') return 0; |
| 124 var lines = info.split("\n"); | 124 var lines = info.split("\n"); |
| 125 RegExp exp = const RegExp(r"Revision: (\d*)"); | 125 RegExp exp = const RegExp(r"Last Changed Rev: (\d*)"); |
| 126 for (var line in lines) { | 126 for (var line in lines) { |
| 127 if (exp.hasMatch(line)) { | 127 if (exp.hasMatch(line)) { |
| 128 String revisionString = (exp.firstMatch(line).group(1)); | 128 String revisionString = (exp.firstMatch(line).group(1)); |
| 129 try { | 129 try { |
| 130 return int.parse(revisionString); | 130 return int.parse(revisionString); |
| 131 } catch(e) { | 131 } catch(e) { |
| 132 return 0; | 132 return 0; |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 return 0; | 136 return 0; |
| 137 } | 137 } |
| 138 | 138 |
| 139 Future<int> getRevision() { | 139 Future<int> getRevision() { |
| 140 if (repositoryType == RepositoryType.UNKNOWN) { | 140 if (repositoryType == RepositoryType.UNKNOWN) { |
| 141 return new Future.immediate(0); | 141 return new Future.immediate(0); |
| 142 } | 142 } |
| 143 var isSvn = repositoryType == RepositoryType.SVN; | 143 var isSvn = repositoryType == RepositoryType.SVN; |
| 144 var command = isSvn ? "svn" : "git"; | 144 var command = isSvn ? "svn" : "git"; |
| 145 command = "$command${getExecutableSuffix()}"; | 145 command = "$command${getExecutableSuffix()}"; |
| 146 var arguments = isSvn ? ["info"] : ["svn", "info"]; | 146 var arguments = isSvn ? ["info"] : ["svn", "info"]; |
| 147 return Process.run(command, arguments).transform((result) { | 147 ProcessOptions options = new ProcessOptions(); |
| 148 // Run the command from the root to get the last changed revision for this |
| 149 // "branch". Since we have both trunk and bleeding edge in the same |
| 150 // repository and since we always build TOT we need this to get the |
| 151 // right version number. |
| 152 Path root = |
| 153 new Path.fromNative(_versionFileName).directoryPath.directoryPath; |
| 154 options.workingDirectory = root.toNativePath(); |
| 155 return Process.run(command, arguments, options).transform((result) { |
| 148 if (result.exitCode != 0) { | 156 if (result.exitCode != 0) { |
| 149 return 0; | 157 return 0; |
| 150 } | 158 } |
| 151 return getRevisionFromSvnInfo(result.stdout); | 159 return getRevisionFromSvnInfo(result.stdout); |
| 152 }); | 160 }); |
| 153 } | 161 } |
| 154 | 162 |
| 155 bool isProductionBuild(String username) { | 163 bool isProductionBuild(String username) { |
| 156 return username == "chrome-bot"; | 164 return username == "chrome-bot"; |
| 157 } | 165 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 187 static RepositoryType guessType() { | 195 static RepositoryType guessType() { |
| 188 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; | 196 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; |
| 189 if (new Directory(".git").existsSync()) return RepositoryType.GIT; | 197 if (new Directory(".git").existsSync()) return RepositoryType.GIT; |
| 190 return RepositoryType.UNKNOWN; | 198 return RepositoryType.UNKNOWN; |
| 191 } | 199 } |
| 192 | 200 |
| 193 String toString() => name; | 201 String toString() => name; |
| 194 | 202 |
| 195 final String name; | 203 final String name; |
| 196 } | 204 } |
| OLD | NEW |