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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/release/version.dart
diff --git a/tools/release/version.dart b/tools/release/version.dart
index 74e1e66363d0dde9d2c933a661e1926ce3ab97be..8e7af38d6e204795eab11ab674813625cd34be9c 100644
--- a/tools/release/version.dart
+++ b/tools/release/version.dart
@@ -189,20 +189,30 @@ class Version {
return username;
}
- bool isGitRepository() {
+ RepositoryType get repositoryType {
+ bool isWindows = Platform.operatingSystem == 'windows';
+ bool hasDirectory(path, name) {
+ return new Directory.fromPath(path.append(name)).existsSync();
+ }
+ bool isFileSystemRoot(absolutePath) {
+ if (isWindows) {
+ return "${absolutePath.directoryPath}" == '/';
+ }
+ return "$absolutePath" == '/';
+ }
+
var currentPath = new Path(new Directory.current().path);
- while (!new Directory.fromPath(currentPath.append(".git")).existsSync()) {
- currentPath = currentPath.directoryPath;
- if (currentPath.toString() == "/") {
+ while (true) {
+ if (hasDirectory(currentPath, '.svn')) {
+ return RepositoryType.SVN;
+ } else if (hasDirectory(currentPath, '.git')) {
+ return RepositoryType.GIT;
+ }
+ if (isFileSystemRoot(currentPath)) {
break;
}
+ currentPath = currentPath.directoryPath;
}
- return new Directory.fromPath(currentPath.append(".git")).existsSync();
- }
-
- RepositoryType get repositoryType {
- if (new Directory(".svn").existsSync()) return RepositoryType.SVN;
- if (isGitRepository()) return RepositoryType.GIT;
return RepositoryType.UNKNOWN;
}
}
« 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