| OLD | NEW |
| 1 // Copyright (c) 2013, 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: |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } catch(e) { | 142 } catch(e) { |
| 143 return 0; | 143 return 0; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 return 0; | 147 return 0; |
| 148 } | 148 } |
| 149 | 149 |
| 150 Future<int> getRevision() { | 150 Future<int> getRevision() { |
| 151 if (repositoryType == RepositoryType.UNKNOWN) { | 151 if (repositoryType == RepositoryType.UNKNOWN) { |
| 152 return new Future.value(0); | 152 return new Future.immediate(0); |
| 153 } | 153 } |
| 154 var isSvn = repositoryType == RepositoryType.SVN; | 154 var isSvn = repositoryType == RepositoryType.SVN; |
| 155 var command = isSvn ? "svn" : "git"; | 155 var command = isSvn ? "svn" : "git"; |
| 156 command = "$command${getExecutableSuffix()}"; | 156 command = "$command${getExecutableSuffix()}"; |
| 157 var arguments = isSvn ? ["info"] : ["svn", "info"]; | 157 var arguments = isSvn ? ["info"] : ["svn", "info"]; |
| 158 ProcessOptions options = new ProcessOptions(); |
| 158 // Run the command from the root to get the last changed revision for this | 159 // Run the command from the root to get the last changed revision for this |
| 159 // "branch". Since we have both trunk and bleeding edge in the same | 160 // "branch". Since we have both trunk and bleeding edge in the same |
| 160 // repository and since we always build TOT we need this to get the | 161 // repository and since we always build TOT we need this to get the |
| 161 // right version number. | 162 // right version number. |
| 162 Path toolsDirectory = new Path(_versionFileName).directoryPath; | 163 Path toolsDirectory = new Path(_versionFileName).directoryPath; |
| 163 Path root = toolsDirectory.join(new Path("..")); | 164 Path root = toolsDirectory.join(new Path("..")); |
| 164 var workingDirectory = root.toNativePath(); | 165 options.workingDirectory = root.toNativePath(); |
| 165 return Process.run(command, | 166 return Process.run(command, arguments, options).then((result) { |
| 166 arguments, | |
| 167 workingDirectory: workingDirectory).then((result) { | |
| 168 if (result.exitCode != 0) { | 167 if (result.exitCode != 0) { |
| 169 return 0; | 168 return 0; |
| 170 } | 169 } |
| 171 return getRevisionFromSvnInfo(result.stdout); | 170 return getRevisionFromSvnInfo(result.stdout); |
| 172 }); | 171 }); |
| 173 } | 172 } |
| 174 | 173 |
| 175 bool isProductionBuild(String username) { | 174 bool isProductionBuild(String username) { |
| 176 return username == "chrome-bot"; | 175 return username == "chrome-bot"; |
| 177 } | 176 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 195 bool hasDirectory(path, name) { | 194 bool hasDirectory(path, name) { |
| 196 return new Directory.fromPath(path.append(name)).existsSync(); | 195 return new Directory.fromPath(path.append(name)).existsSync(); |
| 197 } | 196 } |
| 198 bool isFileSystemRoot(absolutePath) { | 197 bool isFileSystemRoot(absolutePath) { |
| 199 if (isWindows) { | 198 if (isWindows) { |
| 200 return "${absolutePath.directoryPath}" == '/'; | 199 return "${absolutePath.directoryPath}" == '/'; |
| 201 } | 200 } |
| 202 return "$absolutePath" == '/'; | 201 return "$absolutePath" == '/'; |
| 203 } | 202 } |
| 204 | 203 |
| 205 var currentPath = new Path(Directory.current.path); | 204 var currentPath = new Path(new Directory.current().path); |
| 206 while (true) { | 205 while (true) { |
| 207 if (hasDirectory(currentPath, '.svn')) { | 206 if (hasDirectory(currentPath, '.svn')) { |
| 208 return RepositoryType.SVN; | 207 return RepositoryType.SVN; |
| 209 } else if (hasDirectory(currentPath, '.git')) { | 208 } else if (hasDirectory(currentPath, '.git')) { |
| 210 return RepositoryType.GIT; | 209 return RepositoryType.GIT; |
| 211 } | 210 } |
| 212 if (isFileSystemRoot(currentPath)) { | 211 if (isFileSystemRoot(currentPath)) { |
| 213 break; | 212 break; |
| 214 } | 213 } |
| 215 currentPath = currentPath.directoryPath; | 214 currentPath = currentPath.directoryPath; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 228 static RepositoryType guessType() { | 227 static RepositoryType guessType() { |
| 229 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; | 228 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; |
| 230 if (new Directory(".git").existsSync()) return RepositoryType.GIT; | 229 if (new Directory(".git").existsSync()) return RepositoryType.GIT; |
| 231 return RepositoryType.UNKNOWN; | 230 return RepositoryType.UNKNOWN; |
| 232 } | 231 } |
| 233 | 232 |
| 234 String toString() => name; | 233 String toString() => name; |
| 235 | 234 |
| 236 final String name; | 235 final String name; |
| 237 } | 236 } |
| OLD | NEW |