Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWorkflow.php
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | if ($information !== null) { | ||||
$this->getWorkflowName(), | $this->getWorkflowName(), | ||||
get_class($this), | get_class($this), | ||||
phutil_describe_type($information))); | phutil_describe_type($information))); | ||||
} | } | ||||
} | } | ||||
if ($information) { | if ($information) { | ||||
$synopsis = $information->getSynopsis(); | $synopsis = $information->getSynopsis(); | ||||
if (strlen($synopsis)) { | if ($synopsis !== null) { | ||||
$phutil_workflow->setSynopsis($synopsis); | $phutil_workflow->setSynopsis($synopsis); | ||||
} | } | ||||
$examples = $information->getExamples(); | $examples = $information->getExamples(); | ||||
if ($examples) { | if ($examples) { | ||||
$examples = implode("\n", $examples); | $examples = implode("\n", $examples); | ||||
$phutil_workflow->setExamples($examples); | $phutil_workflow->setExamples($examples); | ||||
} | } | ||||
$help = $information->getHelp(); | $help = $information->getHelp(); | ||||
if (strlen($help)) { | if ($help !== null) { | ||||
// Unwrap linebreaks in the help text so we don't get weird formatting. | // Unwrap linebreaks in the help text so we don't get weird formatting. | ||||
$help = preg_replace("/(?<=\S)\n(?=\S)/", ' ', $help); | $help = preg_replace("/(?<=\S)\n(?=\S)/", ' ', $help); | ||||
$phutil_workflow->setHelp($help); | $phutil_workflow->setHelp($help); | ||||
} | } | ||||
} | } | ||||
return $phutil_workflow; | return $phutil_workflow; | ||||
▲ Show 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | try { | ||||
)); | )); | ||||
} catch (ConduitClientException $ex) { | } catch (ConduitClientException $ex) { | ||||
if ($ex->getErrorCode() == 'ERR-NO-CERTIFICATE' || | if ($ex->getErrorCode() == 'ERR-NO-CERTIFICATE' || | ||||
$ex->getErrorCode() == 'ERR-INVALID-USER' || | $ex->getErrorCode() == 'ERR-INVALID-USER' || | ||||
$ex->getErrorCode() == 'ERR-INVALID-AUTH') { | $ex->getErrorCode() == 'ERR-INVALID-AUTH') { | ||||
$conduit_uri = $this->conduitURI; | $conduit_uri = $this->conduitURI; | ||||
$message = phutil_console_format( | $message = phutil_console_format( | ||||
"\n%s\n\n %s\n\n%s\n%s", | "\n%s\n\n %s\n\n%s\n%s", | ||||
pht('YOU NEED TO __INSTALL A CERTIFICATE__ TO LOGIN TO PHABRICATOR'), | pht('YOU NEED TO __INSTALL A CERTIFICATE__ TO LOG IN'), | ||||
pht('To do this, run: **%s**', 'arc install-certificate'), | pht('To do this, run: **%s**', 'arc install-certificate'), | ||||
pht("The server '%s' rejected your request:", $conduit_uri), | pht("The server '%s' rejected your request:", $conduit_uri), | ||||
$ex->getMessage()); | $ex->getMessage()); | ||||
throw new ArcanistUsageException($message); | throw new ArcanistUsageException($message); | ||||
} else if ($ex->getErrorCode() == 'NEW-ARC-VERSION') { | } else if ($ex->getErrorCode() == 'NEW-ARC-VERSION') { | ||||
// Cleverly disguise this as being AWESOME!!! | // Cleverly disguise this as being AWESOME!!! | ||||
▲ Show 20 Lines • Show All 683 Lines • ▼ Show 20 Lines | if ($should_commit) { | ||||
sort($paths); | sort($paths); | ||||
foreach ($paths as $path) { | foreach ($paths as $path) { | ||||
$template .= "# ".$path."\n"; | $template .= "# ".$path."\n"; | ||||
} | } | ||||
$commit_message = $this->newInteractiveEditor($template) | $commit_message = $this->newInteractiveEditor($template) | ||||
->setName(pht('commit-message')) | ->setName(pht('commit-message')) | ||||
->setTaskMessage(pht( | |||||
'Supply commit message for uncommitted changes, then save and '. | |||||
'exit.')) | |||||
->editInteractively(); | ->editInteractively(); | ||||
if ($commit_message === $template) { | if ($commit_message === $template) { | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht('You must provide a commit message.')); | pht('You must provide a commit message.')); | ||||
} | } | ||||
$commit_message = ArcanistCommentRemover::removeComments( | $commit_message = ArcanistCommentRemover::removeComments( | ||||
▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Write a message to stderr so that '--json' flags or stdout which is meant | * Write a message to stderr so that '--json' flags or stdout which is meant | ||||
* to be piped somewhere aren't disrupted. | * to be piped somewhere aren't disrupted. | ||||
* | * | ||||
* @param string Message to write to stderr. | * @param string Message to write to stderr. | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
final protected function writeStatusMessage($msg) { | final protected function writeStatusMessage($msg) { | ||||
fwrite(STDERR, $msg); | PhutilSystem::writeStderr($msg); | ||||
} | } | ||||
final public function writeInfo($title, $message) { | final public function writeInfo($title, $message) { | ||||
$this->writeStatusMessage( | $this->writeStatusMessage( | ||||
phutil_console_format( | phutil_console_format( | ||||
"<bg:blue>** %s **</bg> %s\n", | "<bg:blue>** %s **</bg> %s\n", | ||||
$title, | $title, | ||||
$message)); | $message)); | ||||
▲ Show 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | private function loadRepositoryInformation() { | ||||
try { | try { | ||||
$method = 'repository.query'; | $method = 'repository.query'; | ||||
$results = $this->getConduitEngine() | $results = $this->getConduitEngine() | ||||
->newFuture($method, $query) | ->newFuture($method, $query) | ||||
->resolve(); | ->resolve(); | ||||
} catch (ConduitClientException $ex) { | } catch (ConduitClientException $ex) { | ||||
if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { | if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { | ||||
$reasons[] = pht( | $reasons[] = pht( | ||||
'This version of Arcanist is more recent than the version of '. | 'This software version on the server you are connecting to is out '. | ||||
'Phabricator you are connecting to: the Phabricator install is '. | 'of date and does not have support for identifying repositories '. | ||||
'out of date and does not have support for identifying '. | 'by callsign or URI. Update the server sofwware to enable these '. | ||||
'repositories by callsign or URI. Update Phabricator to enable '. | 'features.'); | ||||
'these features.'); | |||||
return array(null, $reasons); | return array(null, $reasons); | ||||
} | } | ||||
throw $ex; | throw $ex; | ||||
} | } | ||||
$result = null; | $result = null; | ||||
if (!$results) { | if (!$results) { | ||||
$reasons[] = pht( | $reasons[] = pht( | ||||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | private function getBrowserCommand() { | ||||
foreach ($candidates as $cmd => $argv) { | foreach ($candidates as $cmd => $argv) { | ||||
if (Filesystem::binaryExists($cmd)) { | if (Filesystem::binaryExists($cmd)) { | ||||
return $argv; | return $argv; | ||||
} | } | ||||
} | } | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht( | pht( | ||||
"Unable to find a browser command to run. Set '%s' in your ". | 'Unable to find a browser command to run. Set "browser" in your '. | ||||
"Arcanist config to specify a command to use.", | 'configuration to specify a command to use.')); | ||||
'browser')); | |||||
} | } | ||||
/** | /** | ||||
* Ask Phabricator to update the current repository as soon as possible. | * Ask Phabricator to update the current repository as soon as possible. | ||||
* | * | ||||
* Calling this method after pushing commits allows Phabricator to discover | * Calling this method after pushing commits allows Phabricator to discover | ||||
* the commits more quickly, so the system overall is more responsive. | * the commits more quickly, so the system overall is more responsive. | ||||
▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines |
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