Skip to content

Commit

Permalink
fix tab complete for out-of-workdir
Browse files Browse the repository at this point in the history
Summary:
see https://github.com/facebook/phabricator/issues/546 - arc complete blows up when not
in a workdir.

There's no "is ArcanistWorkingCopyIdentity object valid" method, but getVCSType() looks like the
closest match.

git grep for `getProjectRoot` didn't reveal any more problmatic call sites.

Test Plan: `arc [tab] [tab]`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8578
  • Loading branch information
avivey authored and epriestley committed Mar 26, 2014
1 parent 46fe94d commit d0bab7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions scripts/arcanist.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
$need_repository_api;

if ($need_working_copy || $want_working_copy) {
if ($need_working_copy && !$working_copy->getProjectRoot()) {
if ($need_working_copy && !$working_copy->getVCSType()) {
throw new ArcanistUsageException(
"This command must be run in a Git, Mercurial or Subversion working ".
"copy.");
Expand Down Expand Up @@ -286,7 +286,8 @@
$workflow->authenticateConduit();
}

if ($need_repository_api || ($want_repository_api && $working_copy)) {
if ($need_repository_api ||
($want_repository_api && $working_copy->getVCSType())) {
$repository_api = ArcanistRepositoryAPI::newAPIFromConfigurationManager(
$configuration_manager);
$workflow->setRepositoryAPI($repository_api);
Expand Down
4 changes: 2 additions & 2 deletions src/workflow/ArcanistShellCompleteWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public function run() {
// We have to build our own because if we requiresWorkingCopy() we'll throw
// if we aren't in a .arcconfig directory. We probably still can't do much,
// but commands can raise more detailed errors.
$working_copy = ArcanistWorkingCopyIdentity::newFromPath(getcwd());
$configuration_manager = $this->getConfigurationManager();
if ($working_copy->getProjectRoot()) {
$working_copy = ArcanistWorkingCopyIdentity::newFromPath(getcwd());
if ($working_copy->getVCSType()) {
$configuration_manager->setWorkingCopyIdentity($working_copy);
$repository_api = ArcanistRepositoryAPI::newAPIFromConfigurationManager(
$configuration_manager);
Expand Down

0 comments on commit d0bab7f

Please sign in to comment.