mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Make arc shell-complete
more robust.
Summary: Fixes T5122. Add some basic error handling to the `shell-complete` workflow. Test Plan: `arc shell-complete` no longer throws errors. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5122 Differential Revision: https://secure.phabricator.com/D9268
This commit is contained in:
parent
f64dee022e
commit
85b8b2e5f8
1 changed files with 10 additions and 7 deletions
|
@ -30,8 +30,9 @@ EOTEXT
|
||||||
public function getArguments() {
|
public function getArguments() {
|
||||||
return array(
|
return array(
|
||||||
'current' => array(
|
'current' => array(
|
||||||
'help' => 'Current term in the argument list being completed.',
|
|
||||||
'param' => 'cursor_position',
|
'param' => 'cursor_position',
|
||||||
|
'paramtype' => 'int',
|
||||||
|
'help' => 'Current term in the argument list being completed.',
|
||||||
),
|
),
|
||||||
'*' => 'argv',
|
'*' => 'argv',
|
||||||
);
|
);
|
||||||
|
@ -42,7 +43,6 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
|
|
||||||
$pos = $this->getArgument('current');
|
$pos = $this->getArgument('current');
|
||||||
$argv = $this->getArgument('argv', array());
|
$argv = $this->getArgument('argv', array());
|
||||||
$argc = count($argv);
|
$argc = count($argv);
|
||||||
|
@ -50,6 +50,11 @@ EOTEXT
|
||||||
$pos = $argc - 1;
|
$pos = $argc - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($pos > $argc) {
|
||||||
|
throw new ArcanistUsageException(
|
||||||
|
'Specified position is greater than the number of arguments provided.');
|
||||||
|
}
|
||||||
|
|
||||||
// Determine which revision control system the working copy uses, so we
|
// Determine which revision control system the working copy uses, so we
|
||||||
// can filter out commands and flags which aren't supported. If we can't
|
// can filter out commands and flags which aren't supported. If we can't
|
||||||
// figure it out, just return all flags/commands.
|
// figure it out, just return all flags/commands.
|
||||||
|
@ -70,7 +75,7 @@ EOTEXT
|
||||||
|
|
||||||
$arc_config = $this->getArcanistConfiguration();
|
$arc_config = $this->getArcanistConfiguration();
|
||||||
|
|
||||||
if ($pos == 1) {
|
if ($pos <= 1) {
|
||||||
$workflows = $arc_config->buildAllWorkflows();
|
$workflows = $arc_config->buildAllWorkflows();
|
||||||
|
|
||||||
$complete = array();
|
$complete = array();
|
||||||
|
@ -81,8 +86,7 @@ EOTEXT
|
||||||
|
|
||||||
$supported = $workflow->getSupportedRevisionControlSystems();
|
$supported = $workflow->getSupportedRevisionControlSystems();
|
||||||
|
|
||||||
$ok = (in_array('any', $supported)) ||
|
$ok = (in_array('any', $supported) || in_array($vcs, $supported));
|
||||||
(in_array($vcs, $supported));
|
|
||||||
if (!$ok) {
|
if (!$ok) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +150,6 @@ EOTEXT
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$output = array();
|
$output = array();
|
||||||
foreach ($arguments as $argument => $spec) {
|
foreach ($arguments as $argument => $spec) {
|
||||||
if ($argument == '*') {
|
if ($argument == '*') {
|
||||||
|
@ -181,7 +184,7 @@ EOTEXT
|
||||||
$branches = ipull($branches, 'name');
|
$branches = ipull($branches, 'name');
|
||||||
$output = $branches;
|
$output = $branches;
|
||||||
} else {
|
} else {
|
||||||
$output = array("FILE");
|
$output = array('FILE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue