mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
Fetch upstream refs before checking out branch in ChannelCommand (#14896)
https://github.com/flutter/flutter/issues/14893
This commit is contained in:
parent
758c221dc3
commit
91a85ac249
|
@ -92,25 +92,34 @@ class ChannelCommand extends FlutterCommand {
|
|||
}
|
||||
|
||||
static Future<Null> _checkout(String branchName) async {
|
||||
// Get latest refs from upstream.
|
||||
int result = await runCommandAndStreamOutput(
|
||||
<String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/$branchName'],
|
||||
<String>['git', 'fetch'],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
prefix: 'git: ',
|
||||
);
|
||||
|
||||
if (result == 0) {
|
||||
// branch already exists, try just switching to it
|
||||
result = await runCommandAndStreamOutput(
|
||||
<String>['git', 'checkout', branchName],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
prefix: 'git: ',
|
||||
);
|
||||
} else {
|
||||
// branch does not exist, we have to create it
|
||||
result = await runCommandAndStreamOutput(
|
||||
<String>['git', 'checkout', '--track', '-b', branchName, 'origin/$branchName'],
|
||||
<String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/$branchName'],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
prefix: 'git: ',
|
||||
);
|
||||
if (result == 0) {
|
||||
// branch already exists, try just switching to it
|
||||
result = await runCommandAndStreamOutput(
|
||||
<String>['git', 'checkout', branchName],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
prefix: 'git: ',
|
||||
);
|
||||
} else {
|
||||
// branch does not exist, we have to create it
|
||||
result = await runCommandAndStreamOutput(
|
||||
<String>['git', 'checkout', '--track', '-b', branchName, 'origin/$branchName'],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
prefix: 'git: ',
|
||||
);
|
||||
}
|
||||
}
|
||||
if (result != 0)
|
||||
throwToolExit('Switching channels failed with error code $result.', exitCode: result);
|
||||
|
|
Loading…
Reference in a new issue