Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWorkflow.php
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | abstract class ArcanistWorkflow extends Phobject { | ||||
} | } | ||||
public function newPhutilWorkflow() { | public function newPhutilWorkflow() { | ||||
$arguments = $this->getWorkflowArguments(); | $arguments = $this->getWorkflowArguments(); | ||||
assert_instances_of($arguments, 'ArcanistWorkflowArgument'); | assert_instances_of($arguments, 'ArcanistWorkflowArgument'); | ||||
$specs = mpull($arguments, 'getPhutilSpecification'); | $specs = mpull($arguments, 'getPhutilSpecification'); | ||||
$phutil_workflow = id(new ArcanistPhutilWorkflow()) | $phutil_workflow = (new ArcanistPhutilWorkflow()) | ||||
->setName($this->getWorkflowName()) | ->setName($this->getWorkflowName()) | ||||
->setWorkflow($this) | ->setWorkflow($this) | ||||
->setArguments($specs); | ->setArguments($specs); | ||||
$information = $this->getWorkflowInformation(); | $information = $this->getWorkflowInformation(); | ||||
if ($information !== null) { | if ($information !== null) { | ||||
if (!($information instanceof ArcanistWorkflowInformation)) { | if (!($information instanceof ArcanistWorkflowInformation)) { | ||||
Show All 28 Lines | if ($information) { | ||||
$phutil_workflow->setHelp($help); | $phutil_workflow->setHelp($help); | ||||
} | } | ||||
} | } | ||||
return $phutil_workflow; | return $phutil_workflow; | ||||
} | } | ||||
final public function newLegacyPhutilWorkflow() { | final public function newLegacyPhutilWorkflow() { | ||||
$phutil_workflow = id(new ArcanistPhutilWorkflow()) | $phutil_workflow = (new ArcanistPhutilWorkflow()) | ||||
->setName($this->getWorkflowName()); | ->setName($this->getWorkflowName()); | ||||
$arguments = $this->getArguments(); | $arguments = $this->getArguments(); | ||||
$specs = array(); | $specs = array(); | ||||
foreach ($arguments as $key => $argument) { | foreach ($arguments as $key => $argument) { | ||||
if ($key == '*') { | if ($key == '*') { | ||||
$key = $argument; | $key = $argument; | ||||
Show All 24 Lines | final public function newLegacyPhutilWorkflow() { | ||||
if (strlen($help)) { | if (strlen($help)) { | ||||
$phutil_workflow->setHelp($help); | $phutil_workflow->setHelp($help); | ||||
} | } | ||||
return $phutil_workflow; | return $phutil_workflow; | ||||
} | } | ||||
final protected function newWorkflowArgument($key) { | final protected function newWorkflowArgument($key) { | ||||
return id(new ArcanistWorkflowArgument()) | return (new ArcanistWorkflowArgument()) | ||||
->setKey($key); | ->setKey($key); | ||||
} | } | ||||
final protected function newWorkflowInformation() { | final protected function newWorkflowInformation() { | ||||
return new ArcanistWorkflowInformation(); | return new ArcanistWorkflowInformation(); | ||||
} | } | ||||
final public function executeWorkflow(PhutilArgumentParser $args) { | final public function executeWorkflow(PhutilArgumentParser $args) { | ||||
▲ Show 20 Lines • Show All 864 Lines • ▼ Show 20 Lines | if ($externals) { | ||||
$message = pht( | $message = pht( | ||||
'%s submodule(s) have uncommitted or untracked changes:', | '%s submodule(s) have uncommitted or untracked changes:', | ||||
new PhutilNumber(count($externals))); | new PhutilNumber(count($externals))); | ||||
$prompt = pht( | $prompt = pht( | ||||
'Ignore the changes to these %s submodule(s) and continue?', | 'Ignore the changes to these %s submodule(s) and continue?', | ||||
new PhutilNumber(count($externals))); | new PhutilNumber(count($externals))); | ||||
$list = id(new PhutilConsoleList()) | $list = (new PhutilConsoleList()) | ||||
->setWrap(false) | ->setWrap(false) | ||||
->addItems($externals); | ->addItems($externals); | ||||
id(new PhutilConsoleBlock()) | (new PhutilConsoleBlock()) | ||||
->addParagraph($message) | ->addParagraph($message) | ||||
->addList($list) | ->addList($list) | ||||
->draw(); | ->draw(); | ||||
$ok = phutil_console_confirm($prompt, $default_no = false); | $ok = phutil_console_confirm($prompt, $default_no = false); | ||||
if (!$ok) { | if (!$ok) { | ||||
throw new ArcanistUserAbortException(); | throw new ArcanistUserAbortException(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,178 Lines • ▼ Show 20 Lines | if ($configuration_engine) { | ||||
} | } | ||||
if (!$this->repositoryAPI) { | if (!$this->repositoryAPI) { | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
if (!$this->repositoryRef) { | if (!$this->repositoryRef) { | ||||
$ref = id(new ArcanistRepositoryRef()) | $ref = (new ArcanistRepositoryRef()) | ||||
->setPHID($this->getRepositoryPHID()) | ->setPHID($this->getRepositoryPHID()) | ||||
->setBrowseURI($this->getRepositoryURI()); | ->setBrowseURI($this->getRepositoryURI()); | ||||
$this->repositoryRef = $ref; | $this->repositoryRef = $ref; | ||||
} | } | ||||
return $this->repositoryRef; | return $this->repositoryRef; | ||||
} | } | ||||
Show All 10 Lines | public function canHandleSignal($signo) { | ||||
return false; | return false; | ||||
} | } | ||||
public function handleSignal($signo) { | public function handleSignal($signo) { | ||||
return; | return; | ||||
} | } | ||||
final public function newCommand(PhutilExecutableFuture $future) { | final public function newCommand(PhutilExecutableFuture $future) { | ||||
return id(new ArcanistCommand()) | return (new ArcanistCommand()) | ||||
->setLogEngine($this->getLogEngine()) | ->setLogEngine($this->getLogEngine()) | ||||
->setExecutableFuture($future); | ->setExecutableFuture($future); | ||||
} | } | ||||
final public function loadHardpoints( | final public function loadHardpoints( | ||||
$objects, | $objects, | ||||
$requests) { | $requests) { | ||||
return $this->getRuntime()->loadHardpoints($objects, $requests); | return $this->getRuntime()->loadHardpoints($objects, $requests); | ||||
} | } | ||||
protected function newPrompts() { | protected function newPrompts() { | ||||
return array(); | return array(); | ||||
} | } | ||||
protected function newPrompt($key) { | protected function newPrompt($key) { | ||||
return id(new ArcanistPrompt()) | return (new ArcanistPrompt()) | ||||
->setWorkflow($this) | ->setWorkflow($this) | ||||
->setKey($key); | ->setKey($key); | ||||
} | } | ||||
public function hasPrompt($key) { | public function hasPrompt($key) { | ||||
$map = $this->getPromptMap(); | $map = $this->getPromptMap(); | ||||
return isset($map[$key]); | return isset($map[$key]); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | final public function getAbsoluteURI($raw_uri) { | ||||
// If we get a relative URI, guess the correct absolute URI based on | // If we get a relative URI, guess the correct absolute URI based on | ||||
// the Conduit URI. This might not be correct for Conduit over SSH. | // the Conduit URI. This might not be correct for Conduit over SSH. | ||||
$raw_uri = new PhutilURI($raw_uri); | $raw_uri = new PhutilURI($raw_uri); | ||||
if (!strlen($raw_uri->getDomain())) { | if (!strlen($raw_uri->getDomain())) { | ||||
$base_uri = $this->getConduitEngine() | $base_uri = $this->getConduitEngine() | ||||
->getConduitURI(); | ->getConduitURI(); | ||||
$raw_uri = id(new PhutilURI($base_uri)) | $raw_uri = (new PhutilURI($base_uri)) | ||||
->setPath($raw_uri->getPath()); | ->setPath($raw_uri->getPath()); | ||||
} | } | ||||
$raw_uri = phutil_string_cast($raw_uri); | $raw_uri = phutil_string_cast($raw_uri); | ||||
return $raw_uri; | return $raw_uri; | ||||
} | } | ||||
final public function writeToPager($corpus) { | final public function writeToPager($corpus) { | ||||
$is_tty = (function_exists('posix_isatty') && posix_isatty(STDOUT)); | $is_tty = (function_exists('posix_isatty') && posix_isatty(STDOUT)); | ||||
if (!$is_tty) { | if (!$is_tty) { | ||||
echo $corpus; | echo $corpus; | ||||
} else { | } else { | ||||
$pager = $this->getConfig('pager'); | $pager = $this->getConfig('pager'); | ||||
if (!$pager) { | if (!$pager) { | ||||
$pager = array('less', '-R', '--'); | $pager = array('less', '-R', '--'); | ||||
} | } | ||||
// Try to show the content through a pager. | // Try to show the content through a pager. | ||||
$err = id(new PhutilExecPassthru('%Ls', $pager)) | $err = (new PhutilExecPassthru('%Ls', $pager)) | ||||
->write($corpus) | ->write($corpus) | ||||
->resolve(); | ->resolve(); | ||||
// If the pager exits with an error, print the content normally. | // If the pager exits with an error, print the content normally. | ||||
if ($err) { | if ($err) { | ||||
echo $corpus; | echo $corpus; | ||||
} | } | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0