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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 return Process.run(command, arguments).transform((result) { |
148 if (result.exitCode != 0) { | 148 if (result.exitCode != 0) { |
149 return 0; | 149 return 0; |
150 } | 150 } |
151 return getRevisionFromSvnInfo(result.stdout); | 151 return getRevisionFromSvnInfo(result.stdout); |
152 }); | 152 }); |
153 } | 153 } |
154 | 154 |
| 155 bool isProductionBuild(String username) { |
| 156 return username == "chrome-bot"; |
| 157 } |
| 158 |
155 String getUserName() { | 159 String getUserName() { |
156 // TODO(ricow): Don't add this on the buildbot. | 160 // TODO(ricow): Don't add this on the buildbot. |
157 var key = "USER"; | 161 var key = "USER"; |
158 if (Platform.operatingSystem == 'windows') { | 162 if (Platform.operatingSystem == 'windows') { |
159 key = "USERNAME"; | 163 key = "USERNAME"; |
160 } | 164 } |
161 if (!Platform.environment.containsKey(key)) return ""; | 165 if (!Platform.environment.containsKey(key)) return ""; |
162 return Platform.environment[key]; | 166 var username = Platform.environment[key]; |
| 167 // If this is a production build, i.e., this is something we are shipping, |
| 168 // don't suffix the version with the username. |
| 169 if (isProductionBuild(username)) return ""; |
| 170 return username; |
163 } | 171 } |
164 | 172 |
165 RepositoryType get repositoryType { | 173 RepositoryType get repositoryType { |
166 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; | 174 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; |
167 if (new Directory(".git").existsSync()) return RepositoryType.GIT; | 175 if (new Directory(".git").existsSync()) return RepositoryType.GIT; |
168 return RepositoryType.UNKNOWN; | 176 return RepositoryType.UNKNOWN; |
169 } | 177 } |
170 } | 178 } |
171 | 179 |
172 class RepositoryType { | 180 class RepositoryType { |
173 static final RepositoryType SVN = const RepositoryType("SVN"); | 181 static final RepositoryType SVN = const RepositoryType("SVN"); |
174 static final RepositoryType GIT = const RepositoryType("GIT"); | 182 static final RepositoryType GIT = const RepositoryType("GIT"); |
175 static final RepositoryType UNKNOWN = const RepositoryType("UNKNOWN"); | 183 static final RepositoryType UNKNOWN = const RepositoryType("UNKNOWN"); |
176 | 184 |
177 const RepositoryType(String this.name); | 185 const RepositoryType(String this.name); |
178 | 186 |
179 static RepositoryType guessType() { | 187 static RepositoryType guessType() { |
180 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; | 188 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; |
181 if (new Directory(".git").existsSync()) return RepositoryType.GIT; | 189 if (new Directory(".git").existsSync()) return RepositoryType.GIT; |
182 return RepositoryType.UNKNOWN; | 190 return RepositoryType.UNKNOWN; |
183 } | 191 } |
184 | 192 |
185 String toString() => name; | 193 String toString() => name; |
186 | 194 |
187 final String name; | 195 final String name; |
188 } | 196 } |
OLD | NEW |