1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Expose repository info in arcanist.projectinfo

Summary: This is to reduce number of calls from Arcanist.

Test Plan: Called it from web interface.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4146
This commit is contained in:
vrana 2012-12-10 15:02:36 -08:00
parent 6ed02e6ee8
commit 0e53731d1d
4 changed files with 17 additions and 14 deletions

View file

@ -42,10 +42,12 @@ final class ConduitAPI_arcanist_projectinfo_Method
$repository_phid = null; $repository_phid = null;
$tracked = false; $tracked = false;
$encoding = null; $encoding = null;
$dictionary = array();
if ($repository) { if ($repository) {
$repository_phid = $repository->getPHID(); $repository_phid = $repository->getPHID();
$tracked = $repository->isTracked(); $tracked = $repository->isTracked();
$encoding = $repository->getDetail('encoding'); $encoding = $repository->getDetail('encoding');
$dictionary = $repository->toDictionary();
} }
return array( return array(
@ -54,6 +56,7 @@ final class ConduitAPI_arcanist_projectinfo_Method
'repositoryPHID' => $repository_phid, 'repositoryPHID' => $repository_phid,
'tracked' => $tracked, 'tracked' => $tracked,
'encoding' => $encoding, 'encoding' => $encoding,
'repository' => $dictionary,
); );
} }

View file

@ -5,17 +5,4 @@
*/ */
abstract class ConduitAPI_repository_Method extends ConduitAPIMethod { abstract class ConduitAPI_repository_Method extends ConduitAPIMethod {
protected function buildDictForRepository(PhabricatorRepository $repository) {
return array(
'name' => $repository->getName(),
'phid' => $repository->getPHID(),
'callsign' => $repository->getCallsign(),
'vcs' => $repository->getVersionControlSystem(),
'uri' => PhabricatorEnv::getProductionURI($repository->getURI()),
'remoteURI' => (string)$repository->getPublicRemoteURI(),
'tracking' => $repository->getDetail('tracking-enabled'),
'description' => $repository->getDetail('description'),
);
}
} }

View file

@ -37,7 +37,7 @@ final class ConduitAPI_repository_query_Method
$results = array(); $results = array();
foreach ($repositories as $repository) { foreach ($repositories as $repository) {
$results[] = $this->buildDictForRepository($repository); $results[] = $repository->toDictionary();
} }
return $results; return $results;

View file

@ -36,6 +36,19 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
PhabricatorPHIDConstants::PHID_TYPE_REPO); PhabricatorPHIDConstants::PHID_TYPE_REPO);
} }
public function toDictionary() {
return array(
'name' => $this->getName(),
'phid' => $this->getPHID(),
'callsign' => $this->getCallsign(),
'vcs' => $this->getVersionControlSystem(),
'uri' => PhabricatorEnv::getProductionURI($this->getURI()),
'remoteURI' => (string)$this->getPublicRemoteURI(),
'tracking' => $this->getDetail('tracking-enabled'),
'description' => $this->getDetail('description'),
);
}
public function getDetail($key, $default = null) { public function getDetail($key, $default = null) {
return idx($this->details, $key, $default); return idx($this->details, $key, $default);
} }