Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: tools/release/version.dart

Issue 14238039: Make version.dart ready for svn 1.7 checkouts (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 key = "USERNAME"; 182 key = "USERNAME";
183 } 183 }
184 if (!Platform.environment.containsKey(key)) return ""; 184 if (!Platform.environment.containsKey(key)) return "";
185 var username = Platform.environment[key]; 185 var username = Platform.environment[key];
186 // If this is a production build, i.e., this is something we are shipping, 186 // If this is a production build, i.e., this is something we are shipping,
187 // don't suffix the version with the username. 187 // don't suffix the version with the username.
188 if (isProductionBuild(username)) return ""; 188 if (isProductionBuild(username)) return "";
189 return username; 189 return username;
190 } 190 }
191 191
192 bool isGitRepository() { 192 RepositoryType get repositoryType {
193 bool isWindows = Platform.operatingSystem == 'windows';
194 bool hasDirectory(path, name) {
195 return new Directory.fromPath(path.append(name)).existsSync();
196 }
197 bool isFileSystemRoot(absolutePath) {
198 if (isWindows) {
199 return "${absolutePath.directoryPath}" == '/';
200 }
201 return "$absolutePath" == '/';
202 }
203
193 var currentPath = new Path(new Directory.current().path); 204 var currentPath = new Path(new Directory.current().path);
194 while (!new Directory.fromPath(currentPath.append(".git")).existsSync()) { 205 while (true) {
195 currentPath = currentPath.directoryPath; 206 if (hasDirectory(currentPath, '.svn')) {
196 if (currentPath.toString() == "/") { 207 return RepositoryType.SVN;
208 } else if (hasDirectory(currentPath, '.git')) {
209 return RepositoryType.GIT;
210 }
211 if (isFileSystemRoot(currentPath)) {
197 break; 212 break;
198 } 213 }
214 currentPath = currentPath.directoryPath;
199 } 215 }
200 return new Directory.fromPath(currentPath.append(".git")).existsSync();
201 }
202
203 RepositoryType get repositoryType {
204 if (new Directory(".svn").existsSync()) return RepositoryType.SVN;
205 if (isGitRepository()) return RepositoryType.GIT;
206 return RepositoryType.UNKNOWN; 216 return RepositoryType.UNKNOWN;
207 } 217 }
208 } 218 }
209 219
210 class RepositoryType { 220 class RepositoryType {
211 static final RepositoryType SVN = const RepositoryType("SVN"); 221 static final RepositoryType SVN = const RepositoryType("SVN");
212 static final RepositoryType GIT = const RepositoryType("GIT"); 222 static final RepositoryType GIT = const RepositoryType("GIT");
213 static final RepositoryType UNKNOWN = const RepositoryType("UNKNOWN"); 223 static final RepositoryType UNKNOWN = const RepositoryType("UNKNOWN");
214 224
215 const RepositoryType(String this.name); 225 const RepositoryType(String this.name);
216 226
217 static RepositoryType guessType() { 227 static RepositoryType guessType() {
218 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; 228 if (new Directory(".svn").existsSync()) return RepositoryType.SVN;
219 if (new Directory(".git").existsSync()) return RepositoryType.GIT; 229 if (new Directory(".git").existsSync()) return RepositoryType.GIT;
220 return RepositoryType.UNKNOWN; 230 return RepositoryType.UNKNOWN;
221 } 231 }
222 232
223 String toString() => name; 233 String toString() => name;
224 234
225 final String name; 235 final String name;
226 } 236 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698