[flutter_conductor] Lift rev parse in conductor (#92594)

* lift git-rev-parse in conductor start
* remove localFlutterRoot from globals.dart
* make localFlutterRoot getter private
* fix analysis
This commit is contained in:
Christopher Fujino
2021-10-28 08:29:16 -07:00
committed by GitHub
parent 9bd0fef560
commit 45f438071a
6 changed files with 41 additions and 71 deletions

View File

@@ -26,7 +26,7 @@ Future<void> main(List<String> args) async {
);
final Checkouts checkouts = Checkouts(
fileSystem: fileSystem,
parentDirectory: localFlutterRoot.parent,
parentDirectory: _localFlutterRoot.parent,
platform: platform,
processManager: processManager,
stdio: stdio,
@@ -39,6 +39,12 @@ Future<void> main(List<String> args) async {
usageLineLength: 80,
);
final String conductorVersion = (await const Git(processManager).getOutput(
<String>['rev-parse'],
'Get the revision of the current Flutter SDK',
workingDirectory: _localFlutterRoot.path,
)).trim();
<Command<void>>[
RollDevCommand(
checkouts: checkouts,
@@ -48,21 +54,21 @@ Future<void> main(List<String> args) async {
),
CodesignCommand(
checkouts: checkouts,
flutterRoot: localFlutterRoot,
flutterRoot: _localFlutterRoot,
),
StatusCommand(
checkouts: checkouts,
),
StartCommand(
checkouts: checkouts,
flutterRoot: localFlutterRoot,
conductorVersion: conductorVersion,
),
CleanCommand(
checkouts: checkouts,
),
CandidatesCommand(
checkouts: checkouts,
flutterRoot: localFlutterRoot,
flutterRoot: _localFlutterRoot,
),
NextCommand(
checkouts: checkouts,
@@ -81,3 +87,21 @@ Future<void> main(List<String> args) async {
io.exit(1);
}
}
Directory get _localFlutterRoot {
String filePath;
const FileSystem fileSystem = LocalFileSystem();
const Platform platform = LocalPlatform();
filePath = platform.script.toFilePath();
final String checkoutsDirname = fileSystem.path.normalize(
fileSystem.path.join(
fileSystem.path.dirname(filePath), // flutter/dev/conductor/core/bin
'..', // flutter/dev/conductor/core
'..', // flutter/dev/conductor
'..', // flutter/dev
'..', // flutter
),
);
return fileSystem.directory(checkoutsDirname);
}