Unverified Commit 31ee09f6 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

make .prompt() async (#94067)

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