| 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;
|
| }
|
| }
|
|
|