diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -814,6 +814,31 @@ return empty($this->arguments['allow-untracked']); } + final protected function promptForUntracked($api, $untracked) { + $prompt = pht(' y - Ignore %d untracked path(s) and continue', + phutil_count($untracked))."\n". + pht(' ! - Delete %d untracked path(s) and continue', + phutil_count($untracked))."\n". + pht(' N - Abort')."\n". + "[y/!/N] ?"; + + do { + $response = phutil_console_prompt($prompt); + $c = trim(strtolower($response)); + } while ($c != 'y' && $c != 'n' && $c != '!' && $c != ''); + echo "\n"; + + if ($c == '' || $c == 'n') { + throw new ArcanistUserAbortException(); + } + + if ($c == '!') { + foreach ($untracked as $path) { + Filesystem::remove($path); + } + } + } + final public function setCommitMode($mode) { $this->commitMode = $mode; return $this; @@ -931,7 +956,7 @@ if ($untracked) { echo sprintf( "%s\n\n%s", - pht('You have untracked files in this working copy.'), + pht('You have untracked paths in this working copy.'), $working_copy_desc); if ($api instanceof ArcanistGitAPI) { @@ -958,13 +983,7 @@ $hint, $untracked_list); - $prompt = pht( - 'Ignore these %s untracked file(s) and continue?', - phutil_count($untracked)); - - if (!phutil_console_confirm($prompt)) { - throw new ArcanistUserAbortException(); - } + $this->promptForUntracked($api, $untracked); }