mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Fix error behavior of "arc version" when it encounters a library which is not a working copy
Summary: Ref T13504. The API has changed here slightly, and if you run "arc version" without "arcanist/" being a Git working copy, it currently fatals in a misleading way. Instead, reach the error properly. Test Plan: Ran "arc version" after moving aside ".git/", got a helpful error message instead of a confusing "call on null" exception. Maniphest Tasks: T13504 Differential Revision: https://secure.phabricator.com/D21050
This commit is contained in:
parent
63276697eb
commit
5ce1d79717
1 changed files with 14 additions and 6 deletions
|
@ -48,15 +48,23 @@ EOTEXT
|
|||
);
|
||||
|
||||
foreach ($roots as $lib => $root) {
|
||||
$working_copy = ArcanistWorkingCopy::newFromWorkingDirectory($root);
|
||||
$repository_api = $working_copy->newRepositoryAPI();
|
||||
$is_git = false;
|
||||
|
||||
if (!$repository_api instanceof ArcanistGitAPI) {
|
||||
throw new ArcanistUsageException(
|
||||
$working_copy = ArcanistWorkingCopy::newFromWorkingDirectory($root);
|
||||
if ($working_copy) {
|
||||
$repository_api = $working_copy->newRepositoryAPI();
|
||||
if ($repository_api instanceof ArcanistGitAPI) {
|
||||
$is_git = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$is_git) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht(
|
||||
'Library "%s" is not a Git working copy, so no version '.
|
||||
'Library "%s" (at "%s") is not a Git working copy, so no version '.
|
||||
'information can be provided.',
|
||||
$lib));
|
||||
$lib,
|
||||
Filesystem::readablePath($root)));
|
||||
}
|
||||
|
||||
// NOTE: Carefully execute these commands in a way that works on Windows
|
||||
|
|
Loading…
Reference in a new issue