mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Fix the channel-switching logic (#14507)
This commit is contained in:
parent
66ecfb02c2
commit
a441a4030f
@ -92,11 +92,26 @@ class ChannelCommand extends FlutterCommand {
|
||||
}
|
||||
|
||||
static Future<Null> _checkout(String branchName) async {
|
||||
final int result = await runCommandAndStreamOutput(
|
||||
<String>['git', 'checkout', '-b', branchName],
|
||||
int result = await runCommandAndStreamOutput(
|
||||
<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 New Issue
Block a user