1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 17:02:41 +01:00

Expose repository ref rules via "diffusion.repository.search"

Summary:
Depends on D20425. Ref T13277. See PHI1067. There's currently no way to retrieve branch/ref rules over the API, which makes some management operations against a large number of repositories difficult.

Expose these rules to the API.

Test Plan: Called `diffusion.repository.search`, got rules in the result set.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13277

Differential Revision: https://secure.phabricator.com/D20426
This commit is contained in:
epriestley 2019-04-15 06:36:17 -07:00
parent 7a4ef2bad8
commit aed755e1d8

View file

@ -2834,10 +2834,24 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
pht( pht(
'The Almanac Service that hosts this repository, if the '. 'The Almanac Service that hosts this repository, if the '.
'repository is clustered.')), 'repository is clustered.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('refRules')
->setType('map<string, list<string>>')
->setDescription(
pht(
'The "Fetch" and "Permanent Ref" rules for this repository.')),
); );
} }
public function getFieldValuesForConduit() { public function getFieldValuesForConduit() {
$fetch_rules = $this->getFetchRules();
$track_rules = $this->getTrackOnlyRules();
$permanent_rules = $this->getAutocloseOnlyRules();
$fetch_rules = $this->getStringListForConduit($fetch_rules);
$track_rules = $this->getStringListForConduit($track_rules);
$permanent_rules = $this->getStringListForConduit($permanent_rules);
return array( return array(
'name' => $this->getName(), 'name' => $this->getName(),
'vcs' => $this->getVersionControlSystem(), 'vcs' => $this->getVersionControlSystem(),
@ -2846,9 +2860,29 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
'status' => $this->getStatus(), 'status' => $this->getStatus(),
'isImporting' => (bool)$this->isImporting(), 'isImporting' => (bool)$this->isImporting(),
'almanacServicePHID' => $this->getAlmanacServicePHID(), 'almanacServicePHID' => $this->getAlmanacServicePHID(),
'refRules' => array(
'fetchRules' => $fetch_rules,
'trackRules' => $track_rules,
'permanentRefRules' => $permanent_rules,
),
); );
} }
private function getStringListForConduit($list) {
if (!is_array($list)) {
$list = array();
}
foreach ($list as $key => $value) {
$value = (string)$value;
if (!strlen($value)) {
unset($list[$key]);
}
}
return array_values($list);
}
public function getConduitSearchAttachments() { public function getConduitSearchAttachments() {
return array( return array(
id(new DiffusionRepositoryURIsSearchEngineAttachment()) id(new DiffusionRepositoryURIsSearchEngineAttachment())