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

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 hasDirectory(path, name) {
194 return new Directory.fromPath(path.append(name)).existsSync();
195 }
196
193 var currentPath = new Path(new Directory.current().path); 197 var currentPath = new Path(new Directory.current().path);
Bill Hesse 2013/04/29 11:58:56 This is changing to Directory.current, so if versi
kustermann 2013/04/30 09:38:44 Thanks for the hint.
194 while (!new Directory.fromPath(currentPath.append(".git")).existsSync()) { 198 while (true) {
195 currentPath = currentPath.directoryPath; 199 if (hasDirectory(currentPath, '.svn')) {
200 return RepositoryType.SVN;
201 } else if (hasDirectory(currentPath, '.git')) {
202 return RepositoryType.GIT;
203 }
196 if (currentPath.toString() == "/") { 204 if (currentPath.toString() == "/") {
Bill Hesse 2013/04/29 11:58:56 I'm not sure this will work on Windows - paths wil
ricow1 2013/04/30 07:21:28 I think we can fix this by doing: do { } while (
kustermann 2013/04/30 09:38:44 I think this is not doing what we want. It allows
197 break; 205 break;
198 } 206 }
207 currentPath = currentPath.directoryPath;
199 } 208 }
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; 209 return RepositoryType.UNKNOWN;
207 } 210 }
208 } 211 }
209 212
210 class RepositoryType { 213 class RepositoryType {
211 static final RepositoryType SVN = const RepositoryType("SVN"); 214 static final RepositoryType SVN = const RepositoryType("SVN");
212 static final RepositoryType GIT = const RepositoryType("GIT"); 215 static final RepositoryType GIT = const RepositoryType("GIT");
213 static final RepositoryType UNKNOWN = const RepositoryType("UNKNOWN"); 216 static final RepositoryType UNKNOWN = const RepositoryType("UNKNOWN");
214 217
215 const RepositoryType(String this.name); 218 const RepositoryType(String this.name);
216 219
217 static RepositoryType guessType() { 220 static RepositoryType guessType() {
218 if (new Directory(".svn").existsSync()) return RepositoryType.SVN; 221 if (new Directory(".svn").existsSync()) return RepositoryType.SVN;
219 if (new Directory(".git").existsSync()) return RepositoryType.GIT; 222 if (new Directory(".git").existsSync()) return RepositoryType.GIT;
220 return RepositoryType.UNKNOWN; 223 return RepositoryType.UNKNOWN;
221 } 224 }
222 225
223 String toString() => name; 226 String toString() => name;
224 227
225 final String name; 228 final String name;
226 } 229 }
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