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