mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 00:02:40 +01:00
Support inspection of remote refs with "arc inspect remote(...)"
Summary: Ref T13546. Expose remote refs for inspection via "arc inspect". For now, this only works in Mercurial. Test Plan: Ran "arc inspect remote(default)" in Mercurial, got a ref out. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21374
This commit is contained in:
parent
b19985a4bd
commit
89f9eb66a7
4 changed files with 54 additions and 0 deletions
|
@ -419,6 +419,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php',
|
'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php',
|
||||||
'ArcanistRefView' => 'ref/ArcanistRefView.php',
|
'ArcanistRefView' => 'ref/ArcanistRefView.php',
|
||||||
'ArcanistRemoteRef' => 'repository/remote/ArcanistRemoteRef.php',
|
'ArcanistRemoteRef' => 'repository/remote/ArcanistRemoteRef.php',
|
||||||
|
'ArcanistRemoteRefInspector' => 'repository/remote/ArcanistRemoteRefInspector.php',
|
||||||
'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php',
|
'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php',
|
||||||
'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php',
|
'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php',
|
||||||
'ArcanistRepositoryAPIStateTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php',
|
'ArcanistRepositoryAPIStateTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php',
|
||||||
|
@ -1449,6 +1450,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistTerminalStringInterface',
|
'ArcanistTerminalStringInterface',
|
||||||
),
|
),
|
||||||
'ArcanistRemoteRef' => 'ArcanistRef',
|
'ArcanistRemoteRef' => 'ArcanistRef',
|
||||||
|
'ArcanistRemoteRefInspector' => 'ArcanistRefInspector',
|
||||||
'ArcanistRepositoryAPI' => 'Phobject',
|
'ArcanistRepositoryAPI' => 'Phobject',
|
||||||
'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase',
|
'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase',
|
||||||
'ArcanistRepositoryAPIStateTestCase' => 'PhutilTestCase',
|
'ArcanistRepositoryAPIStateTestCase' => 'PhutilTestCase',
|
||||||
|
|
|
@ -3,6 +3,17 @@
|
||||||
abstract class ArcanistRefInspector
|
abstract class ArcanistRefInspector
|
||||||
extends Phobject {
|
extends Phobject {
|
||||||
|
|
||||||
|
private $workflow;
|
||||||
|
|
||||||
|
final public function setWorkflow(ArcanistWorkflow $workflow) {
|
||||||
|
$this->workflow = $workflow;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getWorkflow() {
|
||||||
|
return $this->workflow;
|
||||||
|
}
|
||||||
|
|
||||||
abstract public function getInspectFunctionName();
|
abstract public function getInspectFunctionName();
|
||||||
abstract public function newInspectRef(array $argv);
|
abstract public function newInspectRef(array $argv);
|
||||||
|
|
||||||
|
|
37
src/repository/remote/ArcanistRemoteRefInspector.php
Normal file
37
src/repository/remote/ArcanistRemoteRefInspector.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ArcanistRemoteRefInspector
|
||||||
|
extends ArcanistRefInspector {
|
||||||
|
|
||||||
|
public function getInspectFunctionName() {
|
||||||
|
return 'remote';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newInspectRef(array $argv) {
|
||||||
|
if (count($argv) !== 1) {
|
||||||
|
throw new PhutilArgumentUsageException(
|
||||||
|
pht(
|
||||||
|
'Expected exactly one argument to "remote(...)" with a '.
|
||||||
|
'remote name.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$remote_name = $argv[0];
|
||||||
|
|
||||||
|
$workflow = $this->getWorkflow();
|
||||||
|
$api = $workflow->getRepositoryAPI();
|
||||||
|
|
||||||
|
$ref = $api->newRemoteRefQuery()
|
||||||
|
->withNames(array($remote_name))
|
||||||
|
->executeOne();
|
||||||
|
|
||||||
|
if (!$ref) {
|
||||||
|
throw new PhutilArgumentUsageException(
|
||||||
|
pht(
|
||||||
|
'This working copy has no remote named "%s".',
|
||||||
|
$remote_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -34,6 +34,10 @@ EOTEXT
|
||||||
|
|
||||||
$inspectors = ArcanistRefInspector::getAllInspectors();
|
$inspectors = ArcanistRefInspector::getAllInspectors();
|
||||||
|
|
||||||
|
foreach ($inspectors as $inspector) {
|
||||||
|
$inspector->setWorkflow($this);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$objects) {
|
if (!$objects) {
|
||||||
echo tsprintf(
|
echo tsprintf(
|
||||||
"%s\n\n",
|
"%s\n\n",
|
||||||
|
|
Loading…
Reference in a new issue