Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWorkflow.php
Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | final public function executeWorkflow(PhutilArgumentParser $args) { | ||||
if ($caught) { | if ($caught) { | ||||
throw $caught; | throw $caught; | ||||
} | } | ||||
return $err; | return $err; | ||||
} | } | ||||
final protected function getLogEngine() { | final public function getLogEngine() { | ||||
return $this->getRuntime()->getLogEngine(); | return $this->getRuntime()->getLogEngine(); | ||||
} | } | ||||
protected function runWorkflowCleanup() { | protected function runWorkflowCleanup() { | ||||
// TOOLSETS: Do we need this? | // TOOLSETS: Do we need this? | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,096 Lines • ▼ Show 20 Lines | public function hasPrompt($key) { | ||||
return isset($map[$key]); | return isset($map[$key]); | ||||
} | } | ||||
public function getPromptMap() { | public function getPromptMap() { | ||||
if ($this->promptMap === null) { | if ($this->promptMap === null) { | ||||
$prompts = $this->newPrompts(); | $prompts = $this->newPrompts(); | ||||
assert_instances_of($prompts, 'ArcanistPrompt'); | assert_instances_of($prompts, 'ArcanistPrompt'); | ||||
$prompts[] = $this->newPrompt('arc.state.stash') | |||||
->setDescription( | |||||
pht( | |||||
'Prompts the user to stash changes and continue when the '. | |||||
'working copy has untracked, uncommitted. or unstaged '. | |||||
'changes.')); | |||||
// TODO: Swap to ArrayCheck? | |||||
$map = array(); | $map = array(); | ||||
foreach ($prompts as $prompt) { | foreach ($prompts as $prompt) { | ||||
$key = $prompt->getKey(); | $key = $prompt->getKey(); | ||||
if (isset($map[$key])) { | if (isset($map[$key])) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Workflow ("%s") generates two prompts with the same '. | 'Workflow ("%s") generates two prompts with the same '. | ||||
'key ("%s"). Each prompt a workflow generates must have a '. | 'key ("%s"). Each prompt a workflow generates must have a '. | ||||
'unique key.', | 'unique key.', | ||||
get_class($this), | get_class($this), | ||||
$key)); | $key)); | ||||
} | } | ||||
$map[$key] = $prompt; | $map[$key] = $prompt; | ||||
} | } | ||||
$this->promptMap = $map; | $this->promptMap = $map; | ||||
} | } | ||||
return $this->promptMap; | return $this->promptMap; | ||||
} | } | ||||
protected function getPrompt($key) { | final public function getPrompt($key) { | ||||
$map = $this->getPromptMap(); | $map = $this->getPromptMap(); | ||||
$prompt = idx($map, $key); | $prompt = idx($map, $key); | ||||
if (!$prompt) { | if (!$prompt) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Workflow ("%s") is requesting a prompt ("%s") but it did not '. | 'Workflow ("%s") is requesting a prompt ("%s") but it did not '. | ||||
'generate any prompt with that name in "newPrompts()".', | 'generate any prompt with that name in "newPrompts()".', | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |