]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Use getcwd() which is more reliable than $_SERVER['PWD']
authorjungejason <jun.ge.jason@fb.com>
Sat, 24 Dec 2011 07:48:46 +0000 (23:48 -0800)
committerjungejason <jun.ge.jason@fb.com>
Sat, 24 Dec 2011 23:05:13 +0000 (15:05 -0800)
Summary:
in arcanist we are using $_SERVER['PWD'], but in some cases it
is not returning the correct result. For example, when I'm using
PhpStorm (an php IDE) to launch the script, $_SERVER['PWD'] returns the
path of the binary of the IDE:
/home/jungejason/tools/PhpStorm-107.658/bin, not the path where arcanist
is at. getcwd() returns the correct value.

One difference between getcwd() and $_SERVER['PWD'] is that getcwd()
resolves symlink where $_SERVER['PWD'] does not. From what I can see,
using realpath should work.

Test Plan:
* ran arcanist as normal and it worked;
* run arcanist in PhpStorm and it worked.
* created a symlink pointing to the repository inside which
I ran the arc command, and it worked.
* created a symlink pointing to arcanist project, run `.
* resources/shell/bash-completion`  and it worked

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1285

scripts/arcanist.php
src/workflow/shell-complete/ArcanistShellCompleteWorkflow.php

index 23b06dc0119b72f1a6550fffd4c4834160e0b9f9..1ef7f431923561b4a53e2cbda2824239f315b5e6 100755 (executable)
@@ -63,7 +63,7 @@ if (function_exists('posix_isatty') && !posix_isatty(STDOUT)) {
 }
 
 $args = array_values($args);
-$working_directory = $_SERVER['PWD'];
+$working_directory = getcwd();
 
 try {
 
index 238e2dd7811f3953e52e59caa7166d4e5acccfae..fa18539109cb4b7bee0036336c02a93af4b62d26 100644 (file)
@@ -64,7 +64,7 @@ EOTEXT
     // 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($_SERVER['PWD']);
+    $working_copy = ArcanistWorkingCopyIdentity::newFromPath(getcwd());
     if ($working_copy->getProjectRoot()) {
       $repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
         $working_copy);