]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow users to skip "arc:prompt" by entering no text
authorepriestley <git@epriestley.com>
Tue, 29 Sep 2015 14:09:19 +0000 (07:09 -0700)
committerepriestley <git@epriestley.com>
Tue, 29 Sep 2015 14:09:19 +0000 (07:09 -0700)
Summary:
Fixes T9476. Currently, if you enter no text in "arc:prompt", we abort resolution immediately.

However, this is a bit inconsistent (other rules that fail to resolve are skipped) it is reasonable to put some default rule behind "arc:prompt" so that you can just mash enter to select it. This construction is unusual, but seems fine and sensible to me.

If you're using "arc:prompt" as the last rule, the behavior is the same as before, so this should only make the rule more useful.

Test Plan:
  - Ran `arc which --base 'arc:prompt, git:HEAD^'` with and without the patch.
  - Without the patch, entering no text at "arc:prompt" failed immediately.
  - With the patch, entering no text caused fallback to the "git:HEAD^" rule.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9476

Differential Revision: https://secure.phabricator.com/D14187

src/parser/ArcanistBaseCommitParser.php

index 9650ae1b582451e7040b6e7c4cc87ac41d06b74f..af2a71ffbf3c34c4bfa7e2f9409deab9204d6cf7 100644 (file)
@@ -133,7 +133,13 @@ final class ArcanistBaseCommitParser extends Phobject {
       case 'prompt':
         $reason = pht('it is what you typed when prompted.');
         $this->api->setBaseCommitExplanation($reason);
-        return phutil_console_prompt(pht('Against which commit?'));
+        $result = phutil_console_prompt(pht('Against which commit?'));
+        if (!strlen($result)) {
+          // Allow the user to continue to the next rule by entering no
+          // text.
+          return null;
+        }
+        return $result;
       case 'local':
       case 'user':
       case 'project':