@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Audit - add ability to query by repositories

Summary: Fixes T5862. The Diffusion table uses `id` but all the other infrastructure uses `phid` so just do a quick load of the repositories to get the ids. Long term, we should re-key the table by phid I think.

Test Plan: made a query with a repository and got a proper result set

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5862

Differential Revision: https://secure.phabricator.com/D10245

+38 -2
+19 -2
src/applications/audit/query/PhabricatorCommitSearchEngine.php
··· 59 59 $query->withAuditAwaitingUser($this->requireViewer()); 60 60 } 61 61 62 + $repository_phids = $saved->getParameter('repositoryPHIDs', array()); 63 + if ($repository_phids) { 64 + // $repository_phids need to be mapped to $repository_ids via a subquery 65 + // so make sure $viewer is set...! 66 + $query->setViewer($this->requireViewer()); 67 + $query->withRepositoryPHIDs($repository_phids); 68 + } 69 + 62 70 return $query; 63 71 } 64 72 ··· 71 79 'commitAuthorPHIDs', 72 80 array()); 73 81 $audit_status = $saved->getParameter('auditStatus', null); 82 + $repository_phids = $saved->getParameter('repositoryPHIDs', array()); 74 83 75 84 $phids = array_mergev( 76 85 array( 77 86 $auditor_phids, 78 - $commit_author_phids)); 87 + $commit_author_phids, 88 + $repository_phids)); 79 89 80 90 $handles = id(new PhabricatorHandleQuery()) 81 91 ->setViewer($this->requireViewer()) ··· 100 110 ->setName('auditStatus') 101 111 ->setLabel(pht('Audit Status')) 102 112 ->setOptions($this->getAuditStatusOptions()) 103 - ->setValue($audit_status)); 113 + ->setValue($audit_status)) 114 + ->appendChild( 115 + id(new AphrontFormTokenizerControl()) 116 + ->setLabel(pht('Repositories')) 117 + ->setName('repositoryPHIDs') 118 + ->setDatasource(new DiffusionRepositoryDatasource()) 119 + ->setValue(array_select_keys($handles, $repository_phids))); 120 + 104 121 } 105 122 106 123 protected function getURI($path) {
+19
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 60 60 } 61 61 62 62 /** 63 + * Look up commits in a specific repository. Prefer 64 + * @{method:withRepositoryIDs}; the underyling table is keyed by ID such 65 + * that this method requires a separate initial query to map PHID to ID. 66 + * Furthermore, this method requires calling @{method:setViewer} in 67 + * advance due to the separate query. 68 + */ 69 + public function withRepositoryPHIDs(array $phids) { 70 + $repositories = id (new PhabricatorRepositoryQuery()) 71 + ->setViewer($this->getViewer()) 72 + ->withPHIDs($phids) 73 + ->execute(); 74 + 75 + if (!$repositories) { 76 + throw new PhabricatorEmptyQueryException(); 77 + } 78 + $this->withRepositoryIDs(mpull($repositories, 'getID')); 79 + } 80 + 81 + /** 63 82 * If a default repository is provided, ambiguous commit identifiers will 64 83 * be assumed to belong to the default repository. 65 84 *