Index: src/applications/repository/query/PhabricatorRepositoryQuery.php =================================================================== --- src/applications/repository/query/PhabricatorRepositoryQuery.php +++ src/applications/repository/query/PhabricatorRepositoryQuery.php @@ -21,6 +21,11 @@ const ORDER_NAME = 'order-name'; private $order = self::ORDER_CREATED; + const HOSTED_PHABRICATOR = 'hosted-phab'; + const HOSTED_REMOTE = 'hosted-remote'; + const HOSTED_ALL = 'hosted-all'; + private $hosted = self::HOSTED_ALL; + private $needMostRecentCommits; private $needCommitCounts; private $needProjectPHIDs; @@ -45,6 +50,11 @@ return $this; } + public function withHosted($hosted) { + $this->hosted = $hosted; + return $this; + } + public function withTypes(array $types) { $this->types = $types; return $this; @@ -148,6 +158,24 @@ default: throw new Exception("Unknown status '{$status}'!"); } + + $hosted = $this->hosted; + switch ($hosted) { + case self::HOSTED_PHABRICATOR: + if (!$repo->isHosted()) { + unset($repositories[$key]); + } + break; + case self::HOSTED_REMOTE: + if ($repo->isHosted()) { + unset($repositories[$key]); + } + break; + case self::HOSTED_ALL: + break; + default: + throw new Exception("Uknown hosted failed '${hosted}'!"); + } } return $repositories; Index: src/applications/repository/query/PhabricatorRepositorySearchEngine.php =================================================================== --- src/applications/repository/query/PhabricatorRepositorySearchEngine.php +++ src/applications/repository/query/PhabricatorRepositorySearchEngine.php @@ -9,6 +9,7 @@ $saved->setParameter('callsigns', $request->getStrList('callsigns')); $saved->setParameter('status', $request->getStr('status')); $saved->setParameter('order', $request->getStr('order')); + $saved->setParameter('hosted', $request->getStr('hosted')); $saved->setParameter('types', $request->getArr('types')); $saved->setParameter('name', $request->getStr('name')); @@ -40,6 +41,12 @@ $query->setOrder(head($this->getOrderValues())); } + $hosted = $saved->getParameter('hosted'); + $hosted = idx($this->getHostedValues(), $hosted); + if ($hosted) { + $query->withHosted($hosted); + } + $types = $saved->getParameter('types'); if ($types) { $query->withTypes($types); @@ -78,7 +85,13 @@ ->setName('status') ->setLabel(pht('Status')) ->setValue($saved_query->getParameter('status')) - ->setOptions($this->getStatusOptions())); + ->setOptions($this->getStatusOptions())) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setName('hosted') + ->setLabel(pht('Hosted')) + ->setValue($saved_query->getParameter('hosted')) + ->setOptions($this->getHostedOptions())); $type_control = id(new AphrontFormCheckboxControl()) ->setLabel(pht('Types')); @@ -164,5 +177,20 @@ ); } + private function getHostedOptions() { + return array( + '' => pht('Hosted and Remote Repositories'), + 'phabricator' => pht('Hosted Repositories'), + 'remote' => pht('Remote Repositories'), + ); + } + + private function getHostedValues() { + return array( + '' => PhabricatorRepositoryQuery::HOSTED_ALL, + 'phabricator' => PhabricatorRepositoryQuery::HOSTED_PHABRICATOR, + 'remote' => PhabricatorRepositoryQuery::HOSTED_REMOTE, + ); + } }