Page MenuHomePhabricator

$default_no is misleading / potentially wrong for PhutilConsole::confirm in various workflows
Closed, ResolvedPublic

Description

I was digging around in the arc/libphutil source today and trying to understand the $default_no = false parameter in ArcanistLintWorkflow.

It looks like everything used to use phutil_console_confirm which takes a $default_no = true parameter like so:

function phutil_console_confirm($prompt, $default_no = true) {
  $prompt_options = $default_no ? '[y/N]' : '[Y/n]';

Later, things were migrated to use $console->confirm($prompt, $default_no = false)

But from my (very naive) understanding of libphutil, confirm() on PhutilConsole has a $default parameter, not a $default_no (with the semantic meaning reversed).

However, you still see (e.g. ArcanistLintWorkflow) calling $console->confirm() with the same value for $default_no. It seems to me like this logic is misleading and potentially backwards.

In other words, when migrating from phutil_console_confirm to $console->confirm() did we flip the default value? From reading the lint workflow, where "default_no" is false, the default is "[y/N]".

So many double-negatives...

Event Timeline

sectioneight raised the priority of this task from to Needs Triage.
sectioneight updated the task description. (Show Details)
sectioneight added a project: Arcanist.
sectioneight added a subscriber: sectioneight.

For an example of a conversion, see {D3151}

In other words, I was surprised to discover that the "Apply this patch" prompt default was "N", and it looks like before it was switched from phutil_console_confirm the default used to be "Y".

And if this is indeed a bug, and not just me reading things terribly wrong, I'm happy to submit a patch to flip the binary values and rename, but wanted to make sure I wasn't wasting yall's time if this is just a misunderstanding on my part.

@joshuaspence should I just submit a diff for this? Or am I misunderstanding the code?