2011-01-10 00:22:25 +01:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
2011-12-22 19:23:29 +01:00
|
|
|
sanity_check_environment();
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
require_once dirname(__FILE__).'/__init_script__.php';
|
|
|
|
|
2020-02-17 18:10:10 +01:00
|
|
|
/**
|
|
|
|
* Adjust 'include_path' to add locations where we'll search for libraries.
|
|
|
|
* We look in these places:
|
|
|
|
*
|
|
|
|
* - Next to 'arcanist/'.
|
|
|
|
* - Anywhere in the normal PHP 'include_path'.
|
|
|
|
* - Inside 'arcanist/externals/includes/'.
|
|
|
|
*/
|
|
|
|
function arcanist_adjust_php_include_path() {
|
|
|
|
// The 'arcanist/' directory.
|
|
|
|
$arcanist_dir = dirname(dirname(__FILE__));
|
|
|
|
|
|
|
|
// The parent directory of 'arcanist/'.
|
|
|
|
$parent_dir = dirname($arcanist_dir);
|
|
|
|
|
|
|
|
// The 'arcanist/externals/includes/' directory.
|
|
|
|
$include_dir = implode(
|
|
|
|
DIRECTORY_SEPARATOR,
|
|
|
|
array(
|
|
|
|
$arcanist_dir,
|
|
|
|
'externals',
|
|
|
|
'includes',
|
|
|
|
));
|
|
|
|
|
|
|
|
$php_include_path = ini_get('include_path');
|
|
|
|
$php_include_path = implode(
|
|
|
|
PATH_SEPARATOR,
|
|
|
|
array(
|
|
|
|
$parent_dir,
|
|
|
|
$php_include_path,
|
|
|
|
$include_dir,
|
|
|
|
));
|
|
|
|
|
|
|
|
ini_set('include_path', $php_include_path);
|
|
|
|
}
|
|
|
|
arcanist_adjust_php_include_path();
|
|
|
|
|
2011-02-19 20:36:08 +01:00
|
|
|
ini_set('memory_limit', -1);
|
|
|
|
|
2012-03-08 21:20:26 +01:00
|
|
|
$original_argv = $argv;
|
2014-06-17 00:28:04 +02:00
|
|
|
$base_args = new PhutilArgumentParser($argv);
|
|
|
|
$base_args->parseStandardArguments();
|
|
|
|
$base_args->parsePartial(
|
2012-06-03 17:31:49 +02:00
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'name' => 'load-phutil-library',
|
|
|
|
'param' => 'path',
|
2015-01-06 13:14:04 +01:00
|
|
|
'help' => pht('Load a libphutil library.'),
|
2012-06-03 17:31:49 +02:00
|
|
|
'repeat' => true,
|
|
|
|
),
|
2013-10-26 00:57:38 +02:00
|
|
|
array(
|
|
|
|
'name' => 'arcrc-file',
|
|
|
|
'param' => 'filename',
|
|
|
|
),
|
2012-06-03 17:31:49 +02:00
|
|
|
array(
|
|
|
|
'name' => 'conduit-uri',
|
|
|
|
'param' => 'uri',
|
2015-01-06 13:14:04 +01:00
|
|
|
'help' => pht('Connect to Phabricator install specified by __uri__.'),
|
2012-06-03 17:31:49 +02:00
|
|
|
),
|
2015-05-05 23:02:54 +02:00
|
|
|
array(
|
|
|
|
'name' => 'conduit-token',
|
|
|
|
'param' => 'token',
|
|
|
|
'help' => pht('Use a specific authentication token.'),
|
|
|
|
),
|
2020-02-13 15:01:26 +01:00
|
|
|
array(
|
|
|
|
'name' => 'anonymous',
|
|
|
|
'help' => pht('Run workflow as a public user, without authenticating.'),
|
|
|
|
),
|
2014-06-17 00:28:04 +02:00
|
|
|
array(
|
|
|
|
'name' => 'config',
|
|
|
|
'param' => 'key=value',
|
|
|
|
'repeat' => true,
|
2015-01-06 13:14:04 +01:00
|
|
|
'help' => pht(
|
2014-06-17 00:28:04 +02:00
|
|
|
'Specify a runtime configuration value. This will take precedence '.
|
2015-01-06 13:14:04 +01:00
|
|
|
'over static values, and only affect the current arcanist invocation.'),
|
2014-06-17 00:28:04 +02:00
|
|
|
),
|
|
|
|
));
|
2012-03-08 21:20:26 +01:00
|
|
|
|
2014-06-17 00:28:04 +02:00
|
|
|
$config_trace_mode = $base_args->getArg('trace');
|
2012-06-03 17:31:49 +02:00
|
|
|
|
2014-06-17 00:28:04 +02:00
|
|
|
$force_conduit = $base_args->getArg('conduit-uri');
|
2015-05-05 23:02:54 +02:00
|
|
|
$force_token = $base_args->getArg('conduit-token');
|
2014-06-17 00:28:04 +02:00
|
|
|
$custom_arcrc = $base_args->getArg('arcrc-file');
|
2020-02-13 15:01:26 +01:00
|
|
|
$is_anonymous = $base_args->getArg('anonymous');
|
2014-06-17 00:28:04 +02:00
|
|
|
$load = $base_args->getArg('load-phutil-library');
|
|
|
|
$help = $base_args->getArg('help');
|
|
|
|
$args = array_values($base_args->getUnconsumedArgumentVector());
|
2011-01-10 00:22:25 +01:00
|
|
|
|
2011-12-24 08:48:46 +01:00
|
|
|
$working_directory = getcwd();
|
2012-07-06 19:05:49 +02:00
|
|
|
$console = PhutilConsole::getConsole();
|
2012-10-30 18:44:49 +01:00
|
|
|
$config = null;
|
2012-12-31 01:01:59 +01:00
|
|
|
$workflow = null;
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
try {
|
2015-12-16 15:00:50 +01:00
|
|
|
if ($config_trace_mode) {
|
|
|
|
echo tsprintf(
|
|
|
|
"**<bg:magenta> %s </bg>** %s\n",
|
|
|
|
pht('ARGV'),
|
|
|
|
csprintf('%Ls', $original_argv));
|
2011-01-10 00:22:25 +01:00
|
|
|
|
2015-12-16 15:00:50 +01:00
|
|
|
$libraries = array(
|
|
|
|
'arcanist',
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($libraries as $library_name) {
|
|
|
|
echo tsprintf(
|
|
|
|
"**<bg:magenta> %s </bg>** %s\n",
|
|
|
|
pht('LOAD'),
|
|
|
|
pht(
|
|
|
|
'Loaded "%s" from "%s".',
|
|
|
|
$library_name,
|
|
|
|
phutil_get_library_root($library_name)));
|
|
|
|
}
|
|
|
|
}
|
2012-07-06 19:05:49 +02:00
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
if (!$args) {
|
2012-11-22 17:36:28 +01:00
|
|
|
if ($help) {
|
|
|
|
$args = array('help');
|
|
|
|
} else {
|
2015-01-06 13:14:04 +01:00
|
|
|
throw new ArcanistUsageException(
|
|
|
|
pht('No command provided. Try `%s`.', 'arc help'));
|
2012-11-22 17:36:28 +01:00
|
|
|
}
|
|
|
|
} else if ($help) {
|
|
|
|
array_unshift($args, 'help');
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2013-10-19 01:10:06 +02:00
|
|
|
$configuration_manager = new ArcanistConfigurationManager();
|
2014-05-23 23:06:29 +02:00
|
|
|
if ($custom_arcrc) {
|
|
|
|
$configuration_manager->setUserConfigurationFileLocation($custom_arcrc);
|
|
|
|
}
|
2013-10-19 01:10:06 +02:00
|
|
|
|
|
|
|
$global_config = $configuration_manager->readUserArcConfig();
|
|
|
|
$system_config = $configuration_manager->readSystemArcConfig();
|
2014-06-17 00:28:04 +02:00
|
|
|
$runtime_config = $configuration_manager->applyRuntimeArcConfig($base_args);
|
|
|
|
|
2020-02-17 18:16:01 +01:00
|
|
|
$working_copy =
|
|
|
|
ArcanistWorkingCopyIdentity::newFromPath($working_directory);
|
2013-10-19 01:10:06 +02:00
|
|
|
$configuration_manager->setWorkingCopyIdentity($working_copy);
|
2011-07-01 04:20:41 +02:00
|
|
|
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
// Load additional libraries, which can provide new classes like configuration
|
|
|
|
// overrides, linters and lint engines, unit test engines, etc.
|
2011-07-01 04:20:41 +02:00
|
|
|
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
// If the user specified "--load-phutil-library" one or more times from
|
|
|
|
// the command line, we load those libraries **instead** of whatever else
|
|
|
|
// is configured. This is basically a debugging feature to let you force
|
|
|
|
// specific libraries to load regardless of the state of the world.
|
|
|
|
if ($load) {
|
2013-04-29 21:19:15 +02:00
|
|
|
$console->writeLog(
|
2015-01-06 13:14:04 +01:00
|
|
|
"%s\n",
|
|
|
|
pht(
|
|
|
|
'Using `%s` flag, configuration will be ignored and configured '.
|
|
|
|
'libraries will not be loaded.',
|
|
|
|
'--load-phutil-library'));
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
// Load the flag libraries. These must load, since the user specified them
|
|
|
|
// explicitly.
|
|
|
|
arcanist_load_libraries(
|
|
|
|
$load,
|
|
|
|
$must_load = true,
|
2015-01-06 13:14:04 +01:00
|
|
|
$lib_source = pht('a "%s" flag', '--load-phutil-library'),
|
2012-09-05 20:45:54 +02:00
|
|
|
$working_copy);
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
} else {
|
2012-07-06 19:05:55 +02:00
|
|
|
// Load libraries in system 'load' config. In contrast to global config, we
|
|
|
|
// fail hard here because this file is edited manually, so if 'arc' breaks
|
|
|
|
// that doesn't make it any more difficult to correct.
|
|
|
|
arcanist_load_libraries(
|
|
|
|
idx($system_config, 'load', array()),
|
|
|
|
$must_load = true,
|
2015-01-06 13:14:04 +01:00
|
|
|
$lib_source = pht('the "%s" setting in system config', 'load'),
|
2012-09-05 20:45:54 +02:00
|
|
|
$working_copy);
|
2012-07-06 19:05:55 +02:00
|
|
|
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
// Load libraries in global 'load' config, as per "arc set-config load". We
|
|
|
|
// need to fail softly if these break because errors would prevent the user
|
|
|
|
// from running "arc set-config" to correct them.
|
|
|
|
arcanist_load_libraries(
|
|
|
|
idx($global_config, 'load', array()),
|
|
|
|
$must_load = false,
|
2015-01-06 13:14:04 +01:00
|
|
|
$lib_source = pht('the "%s" setting in global config', 'load'),
|
2012-09-05 20:45:54 +02:00
|
|
|
$working_copy);
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
|
|
|
|
// Load libraries in ".arcconfig". Libraries here must load.
|
|
|
|
arcanist_load_libraries(
|
2013-10-23 00:34:06 +02:00
|
|
|
$working_copy->getProjectConfig('load'),
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
$must_load = true,
|
2015-01-06 13:14:04 +01:00
|
|
|
$lib_source = pht('the "%s" setting in "%s"', 'load', '.arcconfig'),
|
2012-09-05 20:45:54 +02:00
|
|
|
$working_copy);
|
2014-06-17 00:28:04 +02:00
|
|
|
|
|
|
|
// Load libraries in ".arcconfig". Libraries here must load.
|
|
|
|
arcanist_load_libraries(
|
|
|
|
idx($runtime_config, 'load', array()),
|
|
|
|
$must_load = true,
|
2015-01-06 13:14:04 +01:00
|
|
|
$lib_source = pht('the %s argument', '--config "load=[...]"'),
|
2014-06-17 00:28:04 +02:00
|
|
|
$working_copy);
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
2011-02-06 08:32:04 +01:00
|
|
|
|
2013-10-19 01:10:06 +02:00
|
|
|
$user_config = $configuration_manager->readUserConfigurationFile();
|
2020-02-17 18:16:01 +01:00
|
|
|
$config = new ArcanistConfiguration();
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
$command = strtolower($args[0]);
|
2012-02-21 22:16:52 +01:00
|
|
|
$args = array_slice($args, 1);
|
2013-10-19 01:10:06 +02:00
|
|
|
$workflow = $config->selectWorkflow(
|
|
|
|
$command,
|
|
|
|
$args,
|
|
|
|
$configuration_manager,
|
|
|
|
$console);
|
|
|
|
$workflow->setConfigurationManager($configuration_manager);
|
2011-01-10 00:22:25 +01:00
|
|
|
$workflow->setArcanistConfiguration($config);
|
|
|
|
$workflow->setCommand($command);
|
2011-06-14 21:18:40 +02:00
|
|
|
$workflow->setWorkingDirectory($working_directory);
|
2012-02-21 22:16:52 +01:00
|
|
|
$workflow->parseArguments($args);
|
2011-01-10 00:22:25 +01:00
|
|
|
|
2013-10-10 15:18:37 +02:00
|
|
|
// Write the command into the environment so that scripts (for example, local
|
|
|
|
// Git commit hooks) can detect that they're being run via `arc` and change
|
|
|
|
// their behaviors.
|
|
|
|
putenv('ARCANIST='.$command);
|
|
|
|
|
2015-02-03 21:32:46 +01:00
|
|
|
$need_working_copy = $workflow->requiresWorkingCopy();
|
|
|
|
|
2015-02-02 20:54:22 +01:00
|
|
|
$supported_vcs_types = $workflow->getSupportedRevisionControlSystems();
|
2015-02-03 21:32:46 +01:00
|
|
|
$vcs_type = $working_copy->getVCSType();
|
|
|
|
if ($vcs_type || $need_working_copy) {
|
|
|
|
if (!in_array($vcs_type, $supported_vcs_types)) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
pht(
|
|
|
|
'`%s %s` is only supported under %s.',
|
|
|
|
'arc',
|
|
|
|
$workflow->getWorkflowName(),
|
|
|
|
implode(', ', $supported_vcs_types)));
|
|
|
|
}
|
2015-02-02 20:54:22 +01:00
|
|
|
}
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
$need_conduit = $workflow->requiresConduit();
|
|
|
|
$need_auth = $workflow->requiresAuthentication();
|
|
|
|
$need_repository_api = $workflow->requiresRepositoryAPI();
|
|
|
|
|
2012-06-14 01:02:29 +02:00
|
|
|
$want_repository_api = $workflow->desiresRepositoryAPI();
|
|
|
|
$want_working_copy = $workflow->desiresWorkingCopy() ||
|
|
|
|
$want_repository_api;
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
$need_conduit = $need_conduit ||
|
|
|
|
$need_auth;
|
|
|
|
$need_working_copy = $need_working_copy ||
|
|
|
|
$need_repository_api;
|
|
|
|
|
2012-06-14 01:02:29 +02:00
|
|
|
if ($need_working_copy || $want_working_copy) {
|
2014-03-26 01:32:58 +01:00
|
|
|
if ($need_working_copy && !$working_copy->getVCSType()) {
|
2011-01-14 00:36:15 +01:00
|
|
|
throw new ArcanistUsageException(
|
2015-01-06 13:14:04 +01:00
|
|
|
pht(
|
|
|
|
'This command must be run in a Git, Mercurial or Subversion '.
|
|
|
|
'working copy.'));
|
2011-01-14 00:36:15 +01:00
|
|
|
}
|
2013-10-19 01:10:06 +02:00
|
|
|
$configuration_manager->setWorkingCopyIdentity($working_copy);
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2011-07-14 00:03:40 +02:00
|
|
|
if ($force_conduit) {
|
|
|
|
$conduit_uri = $force_conduit;
|
|
|
|
} else {
|
2014-05-13 20:36:56 +02:00
|
|
|
$conduit_uri = $configuration_manager->getConfigFromAnySource(
|
Allow `arc` to identify repositories without "project_id"
Summary:
Ref T4343. Continues the process of reducing the prominence of Arcanist Projects. Primarily:
- Query Phabricator to identify the working copy based on explicit configuration, or guess based on heuristics.
- Enhance `arc which` to explain the process to the user.
- The `project_id` key is no longer required in `.arcconfig`.
Minor/cleanup changes:
- Rename `project_id` to `project.name` (consistency, clarity).
- Rename `conduit_uri` to `phabricator.uri` (consistency, clairty).
- These both need documentation updates.
- Add `repository.callsign` to explicitly bind to a repository.
- Updated `.arcconfig` for the new values.
- Fix a unit test which broke a while ago when we fixed a rare definition of "unstaged".
- Make `getRepositoryUUID()` generic so we can get rid of one `instanceof`.
Test Plan:
- Ran `arc which`.
- Ran `arc diff`.
- This doesn't really change anything, so the only real risk is version compatibility breaks. This //does// introduce such a break, but the window is very narrow: if you upgrade `arc` after this commit, and try to diff against a Phabricator which was updated after yesterday (D8068) but before D8072 lands, the lookup will work so we'll add `repositoryPHID` to the `differential.creatediff` call, but it won't exist in Phabricator yet. This window is so narrow that I'm not going to try to fix it, as I'd guess there is a significant chance that no users will be affected. I don't see a clever way to fix it that doesn't involve a lot of work, either.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T4343
Differential Revision: https://secure.phabricator.com/D8073
2014-01-27 00:31:30 +01:00
|
|
|
'phabricator.uri');
|
2014-05-13 20:36:56 +02:00
|
|
|
if ($conduit_uri === null) {
|
2015-01-06 13:14:04 +01:00
|
|
|
$conduit_uri = $configuration_manager->getConfigFromAnySource('default');
|
Allow 'arc' to run without '.arcconfig'
Summary:
This is mostly an onboarding thing, but also allows "arc upload", "arc download", and "arc paste" to work anywhere on the system.
- Try to read the Phabricator install URI from arc global config if we can't find ".arcconfig".
- Build a WorkingCopy anyway if we can't find ".arcconfig", as long as we can find ".svn", ".git", or ".hg".
- Make all the workflows handle "no project ID" at least somewhat gracefully.
Test Plan:
- Ran "arc diff" in .arcconfig-less Mercurial, Git, and Subversion working copies.
- Ran "arc upload" and "arc download" from my desktop.
- Ran "arc paste" from somewhere random.
- Cleared my config and hit the error, got useful instructions.
Reviewers: btrahan, csilvers
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2424
2012-05-08 00:24:58 +02:00
|
|
|
}
|
2011-07-14 00:03:40 +02:00
|
|
|
}
|
2014-05-13 20:36:56 +02:00
|
|
|
|
2011-07-14 00:03:40 +02:00
|
|
|
if ($conduit_uri) {
|
|
|
|
// Set the URI path to '/api/'. TODO: Originally, I contemplated letting
|
|
|
|
// you deploy Phabricator somewhere other than the domain root, but ended
|
|
|
|
// up never pursuing that. We should get rid of all "/api/" silliness
|
|
|
|
// in things users are expected to configure. This is already happening
|
|
|
|
// to some degree, e.g. "arc install-certificate" does it for you.
|
|
|
|
$conduit_uri = new PhutilURI($conduit_uri);
|
|
|
|
$conduit_uri->setPath('/api/');
|
|
|
|
$conduit_uri = (string)$conduit_uri;
|
|
|
|
}
|
|
|
|
$workflow->setConduitURI($conduit_uri);
|
|
|
|
|
2013-08-04 17:21:35 +02:00
|
|
|
// Apply global CA bundle from configs.
|
2013-10-19 01:10:06 +02:00
|
|
|
$ca_bundle = $configuration_manager->getConfigFromAnySource('https.cabundle');
|
|
|
|
if ($ca_bundle) {
|
2013-08-04 17:21:35 +02:00
|
|
|
$ca_bundle = Filesystem::resolvePath(
|
|
|
|
$ca_bundle, $working_copy->getProjectRoot());
|
|
|
|
HTTPSFuture::setGlobalCABundleFromPath($ca_bundle);
|
|
|
|
}
|
|
|
|
|
2013-09-26 00:26:38 +02:00
|
|
|
$blind_key = 'https.blindly-trust-domains';
|
2013-10-19 01:10:06 +02:00
|
|
|
$blind_trust = $configuration_manager->getConfigFromAnySource($blind_key);
|
2013-09-26 00:26:38 +02:00
|
|
|
if ($blind_trust) {
|
2016-06-09 19:48:32 +02:00
|
|
|
$trust_extension = PhutilHTTPEngineExtension::requireExtension(
|
|
|
|
ArcanistBlindlyTrustHTTPEngineExtension::EXTENSIONKEY);
|
|
|
|
$trust_extension->setDomains($blind_trust);
|
2013-09-26 00:26:38 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 00:03:40 +02:00
|
|
|
if ($need_conduit) {
|
2011-01-10 00:22:25 +01:00
|
|
|
if (!$conduit_uri) {
|
Allow 'arc' to run without '.arcconfig'
Summary:
This is mostly an onboarding thing, but also allows "arc upload", "arc download", and "arc paste" to work anywhere on the system.
- Try to read the Phabricator install URI from arc global config if we can't find ".arcconfig".
- Build a WorkingCopy anyway if we can't find ".arcconfig", as long as we can find ".svn", ".git", or ".hg".
- Make all the workflows handle "no project ID" at least somewhat gracefully.
Test Plan:
- Ran "arc diff" in .arcconfig-less Mercurial, Git, and Subversion working copies.
- Ran "arc upload" and "arc download" from my desktop.
- Ran "arc paste" from somewhere random.
- Cleared my config and hit the error, got useful instructions.
Reviewers: btrahan, csilvers
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2424
2012-05-08 00:24:58 +02:00
|
|
|
|
|
|
|
$message = phutil_console_format(
|
2015-01-06 13:14:04 +01:00
|
|
|
"%s\n\n - %s\n - %s\n - %s\n",
|
|
|
|
pht(
|
|
|
|
'This command requires arc to connect to a Phabricator install, '.
|
|
|
|
'but no Phabricator installation is configured. To configure a '.
|
|
|
|
'Phabricator URI:'),
|
|
|
|
pht(
|
|
|
|
'set a default location with `%s`; or',
|
|
|
|
'arc set-config default <uri>'),
|
|
|
|
pht(
|
|
|
|
'specify `%s` explicitly; or',
|
|
|
|
'--conduit-uri=uri'),
|
|
|
|
pht(
|
|
|
|
"run `%s` in a working copy with an '%s'.",
|
|
|
|
'arc',
|
|
|
|
'.arcconfig'));
|
Allow 'arc' to run without '.arcconfig'
Summary:
This is mostly an onboarding thing, but also allows "arc upload", "arc download", and "arc paste" to work anywhere on the system.
- Try to read the Phabricator install URI from arc global config if we can't find ".arcconfig".
- Build a WorkingCopy anyway if we can't find ".arcconfig", as long as we can find ".svn", ".git", or ".hg".
- Make all the workflows handle "no project ID" at least somewhat gracefully.
Test Plan:
- Ran "arc diff" in .arcconfig-less Mercurial, Git, and Subversion working copies.
- Ran "arc upload" and "arc download" from my desktop.
- Ran "arc paste" from somewhere random.
- Cleared my config and hit the error, got useful instructions.
Reviewers: btrahan, csilvers
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2424
2012-05-08 00:24:58 +02:00
|
|
|
|
|
|
|
$message = phutil_console_wrap($message);
|
|
|
|
throw new ArcanistUsageException($message);
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
2011-07-14 00:03:40 +02:00
|
|
|
$workflow->establishConduit();
|
|
|
|
}
|
2011-02-06 08:32:04 +01:00
|
|
|
|
2011-07-14 00:03:40 +02:00
|
|
|
$hosts_config = idx($user_config, 'hosts', array());
|
|
|
|
$host_config = idx($hosts_config, $conduit_uri, array());
|
|
|
|
$user_name = idx($host_config, 'user');
|
|
|
|
$certificate = idx($host_config, 'cert');
|
2014-12-15 20:12:38 +01:00
|
|
|
$conduit_token = idx($host_config, 'token');
|
2015-05-07 20:09:58 +02:00
|
|
|
if ($force_token) {
|
|
|
|
$conduit_token = $force_token;
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
|
2020-02-13 15:01:26 +01:00
|
|
|
if ($is_anonymous) {
|
|
|
|
$conduit_token = null;
|
|
|
|
}
|
|
|
|
|
2012-03-08 21:20:26 +01:00
|
|
|
$description = implode(' ', $original_argv);
|
2011-07-14 00:03:40 +02:00
|
|
|
$credentials = array(
|
2014-12-15 20:12:38 +01:00
|
|
|
'user' => $user_name,
|
2011-07-14 00:03:40 +02:00
|
|
|
'certificate' => $certificate,
|
|
|
|
'description' => $description,
|
2014-12-15 20:12:38 +01:00
|
|
|
'token' => $conduit_token,
|
2011-07-14 00:03:40 +02:00
|
|
|
);
|
|
|
|
$workflow->setConduitCredentials($credentials);
|
|
|
|
|
2020-02-13 15:01:26 +01:00
|
|
|
$engine = id(new ArcanistConduitEngine())
|
|
|
|
->setConduitURI($conduit_uri)
|
2020-02-17 18:16:01 +01:00
|
|
|
->setConduitToken($conduit_token);
|
2020-02-13 15:01:26 +01:00
|
|
|
|
|
|
|
$workflow->setConduitEngine($engine);
|
|
|
|
|
2011-07-14 00:03:40 +02:00
|
|
|
if ($need_auth) {
|
2014-12-15 20:12:38 +01:00
|
|
|
if ((!$user_name || !$certificate) && (!$conduit_token)) {
|
2013-05-25 05:20:20 +02:00
|
|
|
$arc = 'arc';
|
|
|
|
if ($force_conduit) {
|
|
|
|
$arc .= csprintf(' --conduit-uri=%s', $conduit_uri);
|
|
|
|
}
|
|
|
|
|
2014-12-15 20:12:38 +01:00
|
|
|
$conduit_domain = id(new PhutilURI($conduit_uri))->getDomain();
|
|
|
|
|
2011-06-27 05:43:24 +02:00
|
|
|
throw new ArcanistUsageException(
|
|
|
|
phutil_console_format(
|
2015-01-06 13:14:04 +01:00
|
|
|
"%s\n\n%s\n\n%s **%s:**\n\n $ **{$arc} install-certificate**\n",
|
|
|
|
pht('YOU NEED TO AUTHENTICATE TO CONTINUE'),
|
|
|
|
pht(
|
|
|
|
'You are trying to connect to a server (%s) that you '.
|
|
|
|
'do not have any credentials stored for.',
|
|
|
|
$conduit_domain),
|
|
|
|
pht('To retrieve and store credentials for this server,'),
|
|
|
|
pht('run this command')));
|
2011-06-27 05:43:24 +02:00
|
|
|
}
|
2011-07-14 00:03:40 +02:00
|
|
|
$workflow->authenticateConduit();
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2014-03-26 01:32:58 +01:00
|
|
|
if ($need_repository_api ||
|
|
|
|
($want_repository_api && $working_copy->getVCSType())) {
|
2013-10-19 01:10:06 +02:00
|
|
|
$repository_api = ArcanistRepositoryAPI::newAPIFromConfigurationManager(
|
|
|
|
$configuration_manager);
|
2011-01-10 00:22:25 +01:00
|
|
|
$workflow->setRepositoryAPI($repository_api);
|
|
|
|
}
|
|
|
|
|
2013-10-19 01:10:06 +02:00
|
|
|
$listeners = $configuration_manager->getConfigFromAnySource(
|
|
|
|
'events.listeners');
|
2011-11-10 22:47:45 +01:00
|
|
|
if ($listeners) {
|
|
|
|
foreach ($listeners as $listener) {
|
2012-09-05 20:45:54 +02:00
|
|
|
$console->writeLog(
|
2015-01-06 13:14:04 +01:00
|
|
|
"%s\n",
|
|
|
|
pht("Registering event listener '%s'.", $listener));
|
2012-09-05 20:45:54 +02:00
|
|
|
try {
|
|
|
|
id(new $listener())->register();
|
|
|
|
} catch (PhutilMissingSymbolException $ex) {
|
2014-07-12 16:45:38 +02:00
|
|
|
// Continue anyway, since you may otherwise be unable to run commands
|
2012-10-16 19:01:35 +02:00
|
|
|
// like `arc set-config events.listeners` in order to repair the damage
|
2013-11-20 21:46:38 +01:00
|
|
|
// you've caused. We're writing out the entire exception here because
|
|
|
|
// it might not have been triggered by the listener itself (for example,
|
|
|
|
// the listener might use a bad class in its register() method).
|
2012-09-05 20:45:54 +02:00
|
|
|
$console->writeErr(
|
2015-01-06 13:14:04 +01:00
|
|
|
"%s\n",
|
|
|
|
pht(
|
|
|
|
"ERROR: Failed to load event listener '%s': %s",
|
|
|
|
$listener,
|
|
|
|
$ex->getMessage()));
|
2012-09-05 20:45:54 +02:00
|
|
|
}
|
2011-11-10 22:47:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
$config->willRunWorkflow($command, $workflow);
|
|
|
|
$workflow->willRunWorkflow();
|
2013-03-21 23:51:39 +01:00
|
|
|
try {
|
|
|
|
$err = $workflow->run();
|
|
|
|
$config->didRunWorkflow($command, $workflow, $err);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$workflow->finalize();
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
$workflow->finalize();
|
2012-06-14 01:01:29 +02:00
|
|
|
exit((int)$err);
|
2011-01-10 00:22:25 +01:00
|
|
|
|
2013-01-24 23:45:21 +01:00
|
|
|
} catch (ArcanistNoEffectException $ex) {
|
|
|
|
echo $ex->getMessage()."\n";
|
|
|
|
|
2012-10-16 19:21:56 +02:00
|
|
|
} catch (Exception $ex) {
|
|
|
|
$is_usage = ($ex instanceof ArcanistUsageException);
|
|
|
|
if ($is_usage) {
|
2015-05-28 01:10:32 +02:00
|
|
|
fwrite(STDERR, phutil_console_format(
|
2015-01-06 13:14:04 +01:00
|
|
|
"**%s** %s\n",
|
|
|
|
pht('Usage Exception:'),
|
2020-02-13 15:01:26 +01:00
|
|
|
rtrim($ex->getMessage())));
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2012-10-30 18:44:49 +01:00
|
|
|
if ($config) {
|
|
|
|
$config->didAbortWorkflow($command, $workflow, $ex);
|
|
|
|
}
|
2012-10-16 19:21:56 +02:00
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
if ($config_trace_mode) {
|
2015-05-28 01:10:32 +02:00
|
|
|
fwrite(STDERR, "\n");
|
2011-01-10 00:22:25 +01:00
|
|
|
throw $ex;
|
|
|
|
}
|
|
|
|
|
2012-10-16 19:21:56 +02:00
|
|
|
if (!$is_usage) {
|
2017-04-20 23:50:03 +02:00
|
|
|
fwrite(STDERR, phutil_console_format(
|
|
|
|
"<bg:red>** %s **</bg>\n", pht('Exception')));
|
2014-06-24 01:24:00 +02:00
|
|
|
|
|
|
|
while ($ex) {
|
2015-05-28 01:10:32 +02:00
|
|
|
fwrite(STDERR, $ex->getMessage()."\n");
|
2014-06-24 01:24:00 +02:00
|
|
|
|
|
|
|
if ($ex instanceof PhutilProxyException) {
|
|
|
|
$ex = $ex->getPreviousException();
|
|
|
|
} else {
|
|
|
|
$ex = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-01 17:46:17 +02:00
|
|
|
fwrite(STDERR, phutil_console_format(
|
2015-01-06 13:14:04 +01:00
|
|
|
"(%s)\n",
|
2015-05-28 01:10:32 +02:00
|
|
|
pht('Run with `%s` for a full exception trace.', '--trace')));
|
2012-10-16 19:21:56 +02:00
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
exit(1);
|
|
|
|
}
|
2011-12-22 19:23:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform some sanity checks against the possible diversity of PHP builds in
|
|
|
|
* the wild, like very old versions and builds that were compiled with flags
|
|
|
|
* that exclude core functionality.
|
|
|
|
*/
|
|
|
|
function sanity_check_environment() {
|
2012-09-17 22:53:04 +02:00
|
|
|
// NOTE: We don't have phutil_is_windows() yet here.
|
|
|
|
$is_windows = (DIRECTORY_SEPARATOR != '/');
|
|
|
|
|
|
|
|
// We use stream_socket_pair() which is not available on Windows earlier.
|
|
|
|
$min_version = ($is_windows ? '5.3.0' : '5.2.3');
|
2011-12-22 19:23:29 +01:00
|
|
|
$cur_version = phpversion();
|
|
|
|
if (version_compare($cur_version, $min_version, '<')) {
|
|
|
|
die_with_bad_php(
|
|
|
|
"You are running PHP version '{$cur_version}', which is older than ".
|
|
|
|
"the minimum version, '{$min_version}'. Update to at least ".
|
|
|
|
"'{$min_version}'.");
|
|
|
|
}
|
|
|
|
|
2012-09-17 22:53:04 +02:00
|
|
|
if ($is_windows) {
|
2012-03-05 19:02:37 +01:00
|
|
|
$need_functions = array(
|
|
|
|
'curl_init' => array('builtin-dll', 'php_curl.dll'),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$need_functions = array(
|
2012-05-07 15:06:38 +02:00
|
|
|
'curl_init' => array(
|
|
|
|
'text',
|
|
|
|
"You need to install the cURL PHP extension, maybe with ".
|
|
|
|
"'apt-get install php5-curl' or 'yum install php53-curl' or ".
|
2015-04-05 14:27:52 +02:00
|
|
|
"something similar.",
|
|
|
|
),
|
2012-05-07 15:06:38 +02:00
|
|
|
'json_decode' => array('flag', '--without-json'),
|
2012-03-05 19:02:37 +01:00
|
|
|
);
|
|
|
|
}
|
2011-12-22 19:23:29 +01:00
|
|
|
|
|
|
|
$problems = array();
|
|
|
|
|
|
|
|
$config = null;
|
|
|
|
$show_config = false;
|
2012-03-05 19:02:37 +01:00
|
|
|
foreach ($need_functions as $fname => $resolution) {
|
2011-12-22 19:23:29 +01:00
|
|
|
if (function_exists($fname)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
static $info;
|
|
|
|
if ($info === null) {
|
|
|
|
ob_start();
|
|
|
|
phpinfo(INFO_GENERAL);
|
|
|
|
$info = ob_get_clean();
|
|
|
|
$matches = null;
|
|
|
|
if (preg_match('/^Configure Command =>\s*(.*?)$/m', $info, $matches)) {
|
|
|
|
$config = $matches[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 19:02:37 +01:00
|
|
|
$generic = true;
|
|
|
|
list($what, $which) = $resolution;
|
|
|
|
|
|
|
|
if ($what == 'flag' && strpos($config, $which) !== false) {
|
2011-12-22 19:23:29 +01:00
|
|
|
$show_config = true;
|
2012-03-05 19:02:37 +01:00
|
|
|
$generic = false;
|
2011-12-22 19:23:29 +01:00
|
|
|
$problems[] =
|
2012-03-05 19:02:37 +01:00
|
|
|
"This build of PHP was compiled with the configure flag '{$which}', ".
|
2011-12-22 19:23:29 +01:00
|
|
|
"which means it does not have the function '{$fname}()'. This ".
|
|
|
|
"function is required for arc to run. Rebuild PHP without this flag. ".
|
|
|
|
"You may also be able to build or install the relevant extension ".
|
|
|
|
"separately.";
|
2012-03-05 19:02:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($what == 'builtin-dll') {
|
|
|
|
$generic = false;
|
|
|
|
$problems[] =
|
|
|
|
"Your install of PHP does not have the '{$which}' extension enabled. ".
|
|
|
|
"Edit your php.ini file and uncomment the line which reads ".
|
|
|
|
"'extension={$which}'.";
|
|
|
|
}
|
|
|
|
|
2012-05-07 15:06:38 +02:00
|
|
|
if ($what == 'text') {
|
|
|
|
$generic = false;
|
|
|
|
$problems[] = $which;
|
|
|
|
}
|
|
|
|
|
2012-03-05 19:02:37 +01:00
|
|
|
if ($generic) {
|
2011-12-22 19:23:29 +01:00
|
|
|
$problems[] =
|
|
|
|
"This build of PHP is missing the required function '{$fname}()'. ".
|
|
|
|
"Rebuild PHP or install the extension which provides '{$fname}()'.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($problems) {
|
|
|
|
if ($show_config) {
|
|
|
|
$problems[] = "PHP was built with this configure command:\n\n{$config}";
|
|
|
|
}
|
|
|
|
die_with_bad_php(implode("\n\n", $problems));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function die_with_bad_php($message) {
|
2015-01-06 18:53:11 +01:00
|
|
|
// NOTE: We're bailing because PHP is broken. We can't call any library
|
|
|
|
// functions because they won't be loaded yet.
|
|
|
|
|
|
|
|
echo "\n";
|
|
|
|
echo 'PHP CONFIGURATION ERRORS';
|
|
|
|
echo "\n\n";
|
|
|
|
echo $message;
|
|
|
|
echo "\n\n";
|
2011-12-22 19:23:29 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
|
|
|
|
function arcanist_load_libraries(
|
|
|
|
$load,
|
|
|
|
$must_load,
|
|
|
|
$lib_source,
|
2012-09-05 20:45:54 +02:00
|
|
|
ArcanistWorkingCopyIdentity $working_copy) {
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
|
|
|
|
if (!$load) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-06 19:05:55 +02:00
|
|
|
if (!is_array($load)) {
|
2015-01-06 13:14:04 +01:00
|
|
|
$error = pht(
|
|
|
|
'Libraries specified by %s are invalid; expected a list. '.
|
|
|
|
'Check your configuration.',
|
|
|
|
$lib_source);
|
2012-07-06 19:05:55 +02:00
|
|
|
$console = PhutilConsole::getConsole();
|
2015-01-06 13:14:04 +01:00
|
|
|
$console->writeErr("%s: %s\n", pht('WARNING'), $error);
|
2012-07-06 19:05:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
foreach ($load as $location) {
|
|
|
|
|
|
|
|
// Try to resolve the library location. We look in several places, in
|
|
|
|
// order:
|
|
|
|
//
|
|
|
|
// 1. Inside the working copy. This is for phutil libraries within the
|
|
|
|
// project. For instance "library/src" will resolve to
|
|
|
|
// "./library/src" if it exists.
|
|
|
|
// 2. In the same directory as the working copy. This allows you to
|
|
|
|
// check out a library alongside a working copy and reference it.
|
|
|
|
// If we haven't resolved yet, "library/src" will try to resolve to
|
|
|
|
// "../library/src" if it exists.
|
|
|
|
// 3. Using normal libphutil resolution rules. Generally, this means
|
|
|
|
// that it checks for libraries next to libphutil, then libraries
|
|
|
|
// in the PHP include_path.
|
|
|
|
//
|
|
|
|
// Note that absolute paths will just resolve absolutely through rule (1).
|
|
|
|
|
|
|
|
$resolved = false;
|
|
|
|
|
|
|
|
// Check inside the working copy. This also checks absolute paths, since
|
|
|
|
// they'll resolve absolute and just ignore the project root.
|
|
|
|
$resolved_location = Filesystem::resolvePath(
|
|
|
|
$location,
|
|
|
|
$working_copy->getProjectRoot());
|
|
|
|
if (Filesystem::pathExists($resolved_location)) {
|
|
|
|
$location = $resolved_location;
|
|
|
|
$resolved = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we didn't find anything, check alongside the working copy.
|
|
|
|
if (!$resolved) {
|
|
|
|
$resolved_location = Filesystem::resolvePath(
|
|
|
|
$location,
|
|
|
|
dirname($working_copy->getProjectRoot()));
|
|
|
|
if (Filesystem::pathExists($resolved_location)) {
|
|
|
|
$location = $resolved_location;
|
|
|
|
$resolved = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-05 20:45:54 +02:00
|
|
|
$console = PhutilConsole::getConsole();
|
|
|
|
$console->writeLog(
|
2015-01-06 13:14:04 +01:00
|
|
|
"%s\n",
|
|
|
|
pht("Loading phutil library from '%s'...", $location));
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
|
|
|
|
$error = null;
|
|
|
|
try {
|
2020-02-17 18:10:10 +01:00
|
|
|
phutil_load_library($location);
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
} catch (PhutilBootloaderException $ex) {
|
2015-01-06 13:14:04 +01:00
|
|
|
$error = pht(
|
|
|
|
"Failed to load phutil library at location '%s'. This library ".
|
|
|
|
"is specified by %s. Check that the setting is correct and the ".
|
|
|
|
"library is located in the right place.",
|
|
|
|
$location,
|
|
|
|
$lib_source);
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
if ($must_load) {
|
|
|
|
throw new ArcanistUsageException($error);
|
|
|
|
} else {
|
2015-01-06 13:14:04 +01:00
|
|
|
fwrite(STDERR, phutil_console_wrap(
|
Fix callsites which called libphutil_console_wrap like it were _format
Summary:
7e2df9a attempted to pht() some strings; unfortunately, it assumed
that some things that were calls to phutil_console_wrap() were
actually calls to phutil_console_format(). This produces errors of
the form:
[2015-07-17 21:17:28] ERROR 2: str_repeat() expects parameter 2 to be long, string given at [/usr/local/libphutil/src/console/format.php:162]
#0 str_repeat(string, string) called at [<phutil>/src/console/format.php:162]
#1 phutil_console_wrap(string, string, string) called at [<arcanist>/scripts/arcanist.php:620]
#2 arcanist_load_libraries(array, boolean, string, ArcanistWorkingCopyIdentity) called at [<arcanist>/scripts/arcanist.php:154]
%s: %s
Provide an additional call to phutil_console_format() when necessary,
or simply append the relevant characters if possible.
Test Plan: Caused a library load error
Reviewers: #blessed_reviewers, epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D14053
2015-09-03 21:01:01 +02:00
|
|
|
phutil_console_format("%s: %s\n",
|
|
|
|
pht('WARNING'),
|
|
|
|
$error)));
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
}
|
|
|
|
} catch (PhutilLibraryConflictException $ex) {
|
|
|
|
if ($ex->getLibrary() != 'arcanist') {
|
|
|
|
throw $ex;
|
|
|
|
}
|
2017-07-21 20:38:06 +02:00
|
|
|
|
|
|
|
// NOTE: If you are running `arc` against itself, we ignore the library
|
|
|
|
// conflict created by loading the local `arc` library (in the current
|
|
|
|
// working directory) and continue without loading it.
|
|
|
|
|
|
|
|
// This means we only execute code in the `arcanist/` directory which is
|
|
|
|
// associated with the binary you are running, whereas we would normally
|
|
|
|
// execute local code.
|
|
|
|
|
|
|
|
// This can make `arc` development slightly confusing if your setup is
|
|
|
|
// especially bizarre, but it allows `arc` to be used in automation
|
|
|
|
// workflows more easily. For some context, see PHI13.
|
|
|
|
|
|
|
|
$executing_directory = dirname(dirname(__FILE__));
|
|
|
|
$working_directory = dirname($location);
|
|
|
|
|
|
|
|
fwrite(
|
|
|
|
STDERR,
|
|
|
|
tsprintf(
|
|
|
|
"**<bg:yellow> %s </bg>** %s\n",
|
|
|
|
pht('VERY META'),
|
|
|
|
pht(
|
|
|
|
'You are running one copy of Arcanist (at path "%s") against '.
|
|
|
|
'another copy of Arcanist (at path "%s"). Code in the current '.
|
|
|
|
'working directory will not be loaded or executed.',
|
|
|
|
$executing_directory,
|
|
|
|
$working_directory)));
|
Allow global config to load libraries and set test engines
Summary:
Khan Academy is looking into lint configuration, but doesn't use ".arcconfig" because they have a large number of repositories. Making configuration more flexible generally gives us more options for onboarding installs.
- Currently, only project config (".arcconfig") can load libraries. Allow user config ("~/.arcrc") to load libraries as well.
- Currently, only project config can set lint/unit engines. Allow user config to set default lint/unit engines.
- Add some type checking to "arc set-config".
- Add "arc set-config --show".
Test Plan:
- **load**
- Ran `arc set-config load xxx`, got error about format.
- Ran `arc set-config load ["apple"]`, got warning on running 'arc' commands (no such library) but was able to run 'arc set-config' again to clear it.
- Ran `arc set-config load ["/path/to/a/lib/src/"]`, worked.
- Ran `arc list --trace`, verified my library loaded in addition to `.arcconfig` libraries.
- Ran `arc list --load-phutil-library=xxx --trace`, verified only that library loaded.
- Ran `arc list --trace --load-phutil-library=apple --trace`, got hard error about bad library.
- Set `.arcconfig` to point at a bad library, verified hard error.
- **lint.engine** / **unit.engine**
- Removed lint engine from `.arcconfig`, ran "arc lint", got a run with specified engine.
- Removed unit engine from `.arcconfig`, ran "arc unit", got a run with specified engine.
- **--show**
- Ran `arc set-config --show`.
- **misc**
- Ran `arc get-config`.
Reviewers: csilvers, btrahan, vrana
Reviewed By: csilvers
CC: aran
Differential Revision: https://secure.phabricator.com/D2618
2012-05-31 20:41:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|