Unverified Commit 91a85ac2 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Fetch upstream refs before checking out branch in ChannelCommand (#14896)

https://github.com/flutter/flutter/issues/14893
parent 758c221d
...@@ -92,7 +92,15 @@ class ChannelCommand extends FlutterCommand { ...@@ -92,7 +92,15 @@ class ChannelCommand extends FlutterCommand {
} }
static Future<Null> _checkout(String branchName) async { static Future<Null> _checkout(String branchName) async {
// Get latest refs from upstream.
int result = await runCommandAndStreamOutput( int result = await runCommandAndStreamOutput(
<String>['git', 'fetch'],
workingDirectory: Cache.flutterRoot,
prefix: 'git: ',
);
if (result == 0) {
result = await runCommandAndStreamOutput(
<String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/$branchName'], <String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/$branchName'],
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
prefix: 'git: ', prefix: 'git: ',
...@@ -112,6 +120,7 @@ class ChannelCommand extends FlutterCommand { ...@@ -112,6 +120,7 @@ class ChannelCommand extends FlutterCommand {
prefix: 'git: ', prefix: 'git: ',
); );
} }
}
if (result != 0) if (result != 0)
throwToolExit('Switching channels failed with error code $result.', exitCode: result); throwToolExit('Switching channels failed with error code $result.', exitCode: result);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment