Include git output into error message from channel command (#28658)

This commit is contained in:
Alexander Markov
2019-03-01 10:22:59 -08:00
committed by GitHub
parent be083da9c6
commit 604e9dc683
2 changed files with 22 additions and 6 deletions

View File

@@ -35,7 +35,10 @@ class ChannelCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async {
switch (argResults.rest.length) {
case 0:
await _listChannels(showAll: argResults['all']);
await _listChannels(
showAll: argResults['all'],
verbose: globalResults['verbose']
);
return null;
case 1:
await _switchChannel(argResults.rest[0]);
@@ -45,11 +48,12 @@ class ChannelCommand extends FlutterCommand {
}
}
Future<void> _listChannels({ bool showAll }) async {
Future<void> _listChannels({ bool showAll, bool verbose }) async {
// Beware: currentBranch could contain PII. See getBranchName().
final String currentChannel = FlutterVersion.instance.channel;
final String currentBranch = FlutterVersion.instance.getBranchName();
final Set<String> seenChannels = Set<String>();
final List<String> rawOutput = <String>[];
showAll = showAll || currentChannel != currentBranch;
@@ -58,6 +62,8 @@ class ChannelCommand extends FlutterCommand {
<String>['git', 'branch', '-r'],
workingDirectory: Cache.flutterRoot,
mapFunction: (String line) {
if (verbose)
rawOutput.add(line);
final List<String> split = line.split('/');
if (split.length < 2)
return null;
@@ -74,8 +80,10 @@ class ChannelCommand extends FlutterCommand {
return null;
},
);
if (result != 0)
throwToolExit('List channels failed: $result', exitCode: result);
if (result != 0) {
final String details = verbose ? '\n${rawOutput.join('\n')}' : '';
throwToolExit('List channels failed: $result$details', exitCode: result);
}
}
Future<void> _switchChannel(String branchName) {