make .prompt() async (#94067)
This commit is contained in:
parent
12f5bb2064
commit
31ee09f6bf
@ -28,7 +28,7 @@ abstract class Context {
|
||||
///
|
||||
/// The default implementation reads from STDIN. This can be overriden in UI
|
||||
/// implementations that capture user interaction differently.
|
||||
bool prompt(String message) {
|
||||
Future<bool> prompt(String message) async {
|
||||
stdio.write('${message.trim()} (y/n) ');
|
||||
final String response = stdio.readLineSync().trim();
|
||||
final String firstChar = response[0].toUpperCase();
|
||||
|
@ -141,7 +141,7 @@ class NextContext extends Context {
|
||||
'${state.engine.checkoutPath} before proceeding.\n');
|
||||
}
|
||||
if (autoAccept == false) {
|
||||
final bool response = prompt(
|
||||
final bool response = await prompt(
|
||||
'Are you ready to push your engine branch to the repository '
|
||||
'${state.engine.mirror.url}?',
|
||||
);
|
||||
@ -167,7 +167,7 @@ class NextContext extends Context {
|
||||
].join('\n'));
|
||||
if (autoAccept == false) {
|
||||
// TODO(fujino): actually test if binaries have been codesigned on macOS
|
||||
final bool response = prompt(
|
||||
final bool response = await prompt(
|
||||
'Has CI passed for the engine PR and binaries been codesigned?',
|
||||
);
|
||||
if (!response) {
|
||||
@ -274,7 +274,7 @@ class NextContext extends Context {
|
||||
}
|
||||
|
||||
if (autoAccept == false) {
|
||||
final bool response = prompt(
|
||||
final bool response = await prompt(
|
||||
'Are you ready to push your framework branch to the repository '
|
||||
'${state.framework.mirror.url}?',
|
||||
);
|
||||
@ -308,7 +308,7 @@ class NextContext extends Context {
|
||||
);
|
||||
final String headRevision = await framework.reverseParse('HEAD');
|
||||
if (autoAccept == false) {
|
||||
final bool response = prompt(
|
||||
final bool response = await prompt(
|
||||
'Are you ready to tag commit $headRevision as ${state.releaseVersion}\n'
|
||||
'and push to remote ${state.framework.upstream.url}?',
|
||||
);
|
||||
@ -343,7 +343,7 @@ class NextContext extends Context {
|
||||
dryRun: true,
|
||||
);
|
||||
|
||||
final bool response = prompt('Are you ready to publish this release?');
|
||||
final bool response = await prompt('Are you ready to publish this release?');
|
||||
if (!response) {
|
||||
stdio.printError('Aborting command.');
|
||||
updateState(state, stdio.logs);
|
||||
@ -363,7 +363,7 @@ class NextContext extends Context {
|
||||
'\t$kLuciPackagingConsoleLink',
|
||||
);
|
||||
if (autoAccept == false) {
|
||||
final bool response = prompt('Have all packaging builds finished successfully?');
|
||||
final bool response = await prompt('Have all packaging builds finished successfully?');
|
||||
if (!response) {
|
||||
stdio.printError('Aborting command.');
|
||||
updateState(state, stdio.logs);
|
||||
|
@ -447,7 +447,7 @@ class StartContext extends Context {
|
||||
candidateBranch,
|
||||
FrameworkRepository.defaultBranch,
|
||||
);
|
||||
final bool response = prompt(
|
||||
final bool response = await prompt(
|
||||
'About to tag the release candidate branch branchpoint of $branchPoint '
|
||||
'as $requestedVersion and push it to ${framework.upstreamRemote.url}. '
|
||||
'Is this correct?',
|
||||
|
@ -1055,7 +1055,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('prompt', () {
|
||||
test('can be overridden for different frontend implementations', () {
|
||||
test('can be overridden for different frontend implementations', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Stdio stdio = _UnimplementedStdio.instance;
|
||||
final Checkouts checkouts = Checkouts(
|
||||
@ -1070,7 +1070,7 @@ void main() {
|
||||
stateFile: fileSystem.file('/statefile.json'),
|
||||
);
|
||||
|
||||
final bool response = context.prompt(
|
||||
final bool response = await context.prompt(
|
||||
'A prompt that will immediately be agreed to',
|
||||
);
|
||||
expect(response, true);
|
||||
@ -1149,9 +1149,9 @@ class _TestNextContext extends NextContext {
|
||||
);
|
||||
|
||||
@override
|
||||
bool prompt(String message) {
|
||||
Future<bool> prompt(String message) {
|
||||
// always say yes
|
||||
return true;
|
||||
return Future<bool>.value(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user