mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Use getcwd() which is more reliable than $_SERVER['PWD']
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
This commit is contained in:
parent
cf00c44cc3
commit
6910fd77a4
2 changed files with 2 additions and 2 deletions
|
@ -63,7 +63,7 @@ if (function_exists('posix_isatty') && !posix_isatty(STDOUT)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = array_values($args);
|
$args = array_values($args);
|
||||||
$working_directory = $_SERVER['PWD'];
|
$working_directory = getcwd();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ EOTEXT
|
||||||
// We have to build our own because if we requiresWorkingCopy() we'll throw
|
// 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,
|
// if we aren't in a .arcconfig directory. We probably still can't do much,
|
||||||
// but commands can raise more detailed errors.
|
// but commands can raise more detailed errors.
|
||||||
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($_SERVER['PWD']);
|
$working_copy = ArcanistWorkingCopyIdentity::newFromPath(getcwd());
|
||||||
if ($working_copy->getProjectRoot()) {
|
if ($working_copy->getProjectRoot()) {
|
||||||
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
|
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
|
||||||
$working_copy);
|
$working_copy);
|
||||||
|
|
Loading…
Reference in a new issue