Page MenuHomePhabricator

D10245.id24723.diff
No OneTemporary

D10245.id24723.diff

diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php
--- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php
+++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php
@@ -59,6 +59,14 @@
$query->withAuditAwaitingUser($this->requireViewer());
}
+ $repository_phids = $saved->getParameter('repositoryPHIDs', array());
+ if ($repository_phids) {
+ // $repository_phids need to be mapped to $repository_ids via a subquery
+ // so make sure $viewer is set...!
+ $query->setViewer($this->requireViewer());
+ $query->withRepositoryPHIDs($repository_phids);
+ }
+
return $query;
}
@@ -71,11 +79,13 @@
'commitAuthorPHIDs',
array());
$audit_status = $saved->getParameter('auditStatus', null);
+ $repository_phids = $saved->getParameter('repositoryPHIDs', array());
$phids = array_mergev(
array(
$auditor_phids,
- $commit_author_phids));
+ $commit_author_phids,
+ $repository_phids));
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
@@ -100,7 +110,14 @@
->setName('auditStatus')
->setLabel(pht('Audit Status'))
->setOptions($this->getAuditStatusOptions())
- ->setValue($audit_status));
+ ->setValue($audit_status))
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setLabel(pht('Repositories'))
+ ->setName('repositoryPHIDs')
+ ->setDatasource(new DiffusionRepositoryDatasource())
+ ->setValue(array_select_keys($handles, $repository_phids)));
+
}
protected function getURI($path) {
diff --git a/src/applications/diffusion/query/DiffusionCommitQuery.php b/src/applications/diffusion/query/DiffusionCommitQuery.php
--- a/src/applications/diffusion/query/DiffusionCommitQuery.php
+++ b/src/applications/diffusion/query/DiffusionCommitQuery.php
@@ -60,6 +60,25 @@
}
/**
+ * Look up commits in a specific repository. Prefer
+ * @{method:withRepositoryIDs}; the underyling table is keyed by ID such
+ * that this method requires a separate initial query to map PHID to ID.
+ * Furthermore, this method requires calling @{method:setViewer} in
+ * advance due to the separate query.
+ */
+ public function withRepositoryPHIDs(array $phids) {
+ $repositories = id (new PhabricatorRepositoryQuery())
+ ->setViewer($this->getViewer())
+ ->withPHIDs($phids)
+ ->execute();
+
+ if (!$repositories) {
+ throw new PhabricatorEmptyQueryException();
+ }
+ $this->withRepositoryIDs(mpull($repositories, 'getID'));
+ }
+
+ /**
* If a default repository is provided, ambiguous commit identifiers will
* be assumed to belong to the default repository.
*

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 3:43 AM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705553
Default Alt Text
D10245.id24723.diff (2 KB)

Event Timeline