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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 var isSvn = repositoryType == RepositoryType.SVN; | 153 var isSvn = repositoryType == RepositoryType.SVN; |
154 var command = isSvn ? "svn" : "git"; | 154 var command = isSvn ? "svn" : "git"; |
155 command = "$command${getExecutableSuffix()}"; | 155 command = "$command${getExecutableSuffix()}"; |
156 var arguments = isSvn ? ["info"] : ["svn", "info"]; | 156 var arguments = isSvn ? ["info"] : ["svn", "info"]; |
157 ProcessOptions options = new ProcessOptions(); | 157 ProcessOptions options = new ProcessOptions(); |
158 // 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 |
159 // "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 |
160 // 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 |
161 // right version number. | 161 // right version number. |
162 Path toolsDirectory = new Path.fromNative(_versionFileName).directoryPath; | 162 Path toolsDirectory = new Path(_versionFileName).directoryPath; |
163 Path root = toolsDirectory.join(new Path("..")); | 163 Path root = toolsDirectory.join(new Path("..")); |
164 options.workingDirectory = root.toNativePath(); | 164 options.workingDirectory = root.toNativePath(); |
165 return Process.run(command, arguments, options).then((result) { | 165 return Process.run(command, arguments, options).then((result) { |
166 if (result.exitCode != 0) { | 166 if (result.exitCode != 0) { |
167 return 0; | 167 return 0; |
168 } | 168 } |
169 return getRevisionFromSvnInfo(result.stdout); | 169 return getRevisionFromSvnInfo(result.stdout); |
170 }); | 170 }); |
171 } | 171 } |
172 | 172 |
173 bool isProductionBuild(String username) { | 173 bool isProductionBuild(String username) { |
174 return username == "chrome-bot"; | 174 return username == "chrome-bot"; |
175 } | 175 } |
176 | 176 |
177 String getUserName() { | 177 String getUserName() { |
178 // TODO(ricow): Don't add this on the buildbot. | 178 // TODO(ricow): Don't add this on the buildbot. |
179 var key = "USER"; | 179 var key = "USER"; |
180 if (Platform.operatingSystem == 'windows') { | 180 if (Platform.operatingSystem == 'windows') { |
181 key = "USERNAME"; | 181 key = "USERNAME"; |
182 } | 182 } |
183 if (!Platform.environment.containsKey(key)) return ""; | 183 if (!Platform.environment.containsKey(key)) return ""; |
184 var username = Platform.environment[key]; | 184 var username = Platform.environment[key]; |
185 // If this is a production build, i.e., this is something we are shipping, | 185 // If this is a production build, i.e., this is something we are shipping, |
186 // don't suffix the version with the username. | 186 // don't suffix the version with the username. |
187 if (isProductionBuild(username)) return ""; | 187 if (isProductionBuild(username)) return ""; |
188 return username; | 188 return username; |
189 } | 189 } |
190 | 190 |
191 bool isGitRepository() { | 191 bool isGitRepository() { |
192 var currentPath = new Path.fromNative(new Directory.current().path); | 192 var currentPath = new Path(new Directory.current().path); |
193 while (!new Directory.fromPath(currentPath.append(".git")).existsSync()) { | 193 while (!new Directory.fromPath(currentPath.append(".git")).existsSync()) { |
194 currentPath = currentPath.directoryPath; | 194 currentPath = currentPath.directoryPath; |
195 if (currentPath.toString() == "/") { | 195 if (currentPath.toString() == "/") { |
196 break; | 196 break; |
197 } | 197 } |
198 } | 198 } |
199 return new Directory.fromPath(currentPath.append(".git")).existsSync(); | 199 return new Directory.fromPath(currentPath.append(".git")).existsSync(); |
200 } | 200 } |
201 | 201 |
202 RepositoryType get repositoryType { | 202 RepositoryType get repositoryType { |
(...skipping 13 matching lines...) Expand all Loading... |
216 static RepositoryType guessType() { | 216 static RepositoryType guessType() { |
217 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; | 217 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; |
218 if (new Directory(".git").existsSync()) return RepositoryType.GIT; | 218 if (new Directory(".git").existsSync()) return RepositoryType.GIT; |
219 return RepositoryType.UNKNOWN; | 219 return RepositoryType.UNKNOWN; |
220 } | 220 } |
221 | 221 |
222 String toString() => name; | 222 String toString() => name; |
223 | 223 |
224 final String name; | 224 final String name; |
225 } | 225 } |
OLD | NEW |