1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Restore "arc alias" shell aliases

Summary:
See <https://discourse.phabricator-community.org/t/exception-when-trying-to-run-an-arc-alias-undefined-method-arcanistalias-getshellcommand/3731/>.

Shell aliases got lost in the shuffle of porting "arc alias"; restore them.

Test Plan: Bound `arc ls` to `ls -alh`, ran `arc ls`.

Differential Revision: https://secure.phabricator.com/D21084
This commit is contained in:
epriestley 2020-04-10 05:17:55 -07:00
parent fff2fc8bc9
commit 387027eb3a
2 changed files with 32 additions and 6 deletions

View file

@ -141,6 +141,12 @@ final class ArcanistRuntime {
->setConfigurationSourceList($config)
->resolveAliases($unconsumed_argv);
foreach ($alias_effects as $alias_effect) {
if ($alias_effect->getType() === ArcanistAliasEffect::EFFECT_SHELL) {
return $this->executeShellAlias($alias_effect);
}
}
$result_argv = $this->applyAliasEffects($alias_effects, $unconsumed_argv);
$args->setUnconsumedArgumentVector($result_argv);
@ -727,4 +733,15 @@ final class ArcanistRuntime {
return $engine;
}
private function executeShellAlias(ArcanistAliasEffect $effect) {
$log = $this->getLogEngine();
$message = $effect->getMessage();
if ($message !== null) {
$log->writeHint(pht('SHELL ALIAS'), $message);
}
return phutil_passthru('%Ls', $effect->getArguments());
}
}

View file

@ -199,22 +199,31 @@ final class ArcanistAliasEngine
}
}
$alias_argv = $alias->getCommand();
$alias_command = array_shift($alias_argv);
if ($alias->isShellCommandAlias()) {
$shell_command = substr($alias_command, 1);
$shell_argv = array_merge(
array($shell_command),
$alias_argv,
$argv);
$shell_display = csprintf('%Ls', $shell_argv);
$results[] = $this->newEffect(ArcanistAliasEffect::EFFECT_SHELL)
->setMessage(
pht(
'%s %s -> $ %s',
$toolset_key,
$command,
$alias->getShellCommand()))
->setCommand($command)
->setArgv($argv);
$shell_display))
->setArguments($shell_argv);
return $results;
}
$alias_argv = $alias->getCommand();
$alias_command = array_shift($alias_argv);
if (isset($stack[$alias_command])) {
$cycle = array_keys($stack);