From bd068f50d5d7fd8b8c9e156c82d1550934bb3205 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 16 Apr 2020 15:50:03 -0700 Subject: [PATCH] [flutter_tools] remove bogus same repo check (#54294) --- .../src/runner/flutter_command_runner.dart | 65 ------------------- 1 file changed, 65 deletions(-) diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index 1eb61bf845..5059c4054e 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -301,7 +301,6 @@ class FlutterCommandRunner extends CommandRunner { globals.flutterUsage.suppressAnalytics = true; } - _checkFlutterCopy(); try { await globals.flutterVersion.ensureVersionFile(); } on FileSystemException catch (e) { @@ -481,68 +480,4 @@ class FlutterCommandRunner extends CommandRunner { return projectPaths; } - - void _checkFlutterCopy() { - // If the current directory is contained by a flutter repo, check that it's - // the same flutter that is currently running. - String directory = globals.fs.path.normalize(globals.fs.path.absolute(globals.fs.currentDirectory.path)); - - // Check if the cwd is a flutter dir. - while (directory.isNotEmpty) { - if (_isDirectoryFlutterRepo(directory)) { - if (!_compareResolvedPaths(directory, Cache.flutterRoot)) { - globals.printError(userMessages.runnerWrongFlutterInstance(Cache.flutterRoot, directory)); - } - - break; - } - - final String parent = globals.fs.path.dirname(directory); - if (parent == directory) { - break; - } - directory = parent; - } - - // Check that the flutter running is that same as the one referenced in the pubspec. - if (globals.fs.isFileSync(kPackagesFileName)) { - final PackageMap packageMap = PackageMap(kPackagesFileName, fileSystem: globals.fs); - Uri flutterUri; - try { - flutterUri = packageMap.map['flutter']; - } on FormatException { - // We're not quite sure why this can happen, perhaps the user - // accidentally edited the .packages file. Re-running pub should - // fix the issue, and we definitely shouldn't crash here. - globals.printTrace('Failed to parse .packages file to check flutter dependency.'); - return; - } - - if (flutterUri != null && (flutterUri.scheme == 'file' || flutterUri.scheme == '')) { - // .../flutter/packages/flutter/lib - final Uri rootUri = flutterUri.resolve('../../..'); - final String flutterPath = globals.fs.path.normalize(globals.fs.file(rootUri).absolute.path); - - if (!globals.fs.isDirectorySync(flutterPath)) { - globals.printError(userMessages.runnerRemovedFlutterRepo(Cache.flutterRoot, flutterPath)); - } else if (!_compareResolvedPaths(flutterPath, Cache.flutterRoot)) { - globals.printError(userMessages.runnerChangedFlutterRepo(Cache.flutterRoot, flutterPath)); - } - } - } - } - - // Check if `bin/flutter` and `bin/cache/engine.stamp` exist. - bool _isDirectoryFlutterRepo(String directory) { - return - globals.fs.isFileSync(globals.fs.path.join(directory, 'bin/flutter')) && - globals.fs.isFileSync(globals.fs.path.join(directory, 'bin/cache/engine.stamp')); - } -} - -bool _compareResolvedPaths(String path1, String path2) { - path1 = globals.fs.directory(globals.fs.path.absolute(path1)).resolveSymbolicLinksSync(); - path2 = globals.fs.directory(globals.fs.path.absolute(path2)).resolveSymbolicLinksSync(); - - return path1 == path2; }