Page MenuHomePhabricator

D19556.diff
No OneTemporary

D19556.diff

diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php b/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
--- a/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
@@ -12,6 +12,7 @@
private $pushEventPHIDs;
private $epochMin;
private $epochMax;
+ private $blockingHeraldRulePHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -54,6 +55,11 @@
return $this;
}
+ public function withBlockingHeraldRulePHIDs(array $phids) {
+ $this->blockingHeraldRulePHIDs = $phids;
+ return $this;
+ }
+
public function newResultObject() {
return new PhabricatorRepositoryPushLog();
}
@@ -89,71 +95,105 @@
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
- 'id IN (%Ld)',
+ 'log.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
- 'phid IN (%Ls)',
+ 'log.phid IN (%Ls)',
$this->phids);
}
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf(
$conn,
- 'repositoryPHID IN (%Ls)',
+ 'log.repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
if ($this->pusherPHIDs !== null) {
$where[] = qsprintf(
$conn,
- 'pusherPHID in (%Ls)',
+ 'log.pusherPHID in (%Ls)',
$this->pusherPHIDs);
}
if ($this->pushEventPHIDs !== null) {
$where[] = qsprintf(
$conn,
- 'pushEventPHID in (%Ls)',
+ 'log.pushEventPHID in (%Ls)',
$this->pushEventPHIDs);
}
if ($this->refTypes !== null) {
$where[] = qsprintf(
$conn,
- 'refType IN (%Ls)',
+ 'log.refType IN (%Ls)',
$this->refTypes);
}
if ($this->newRefs !== null) {
$where[] = qsprintf(
$conn,
- 'refNew IN (%Ls)',
+ 'log.refNew IN (%Ls)',
$this->newRefs);
}
if ($this->epochMin !== null) {
$where[] = qsprintf(
$conn,
- 'epoch >= %d',
+ 'log.epoch >= %d',
$this->epochMin);
}
if ($this->epochMax !== null) {
$where[] = qsprintf(
$conn,
- 'epoch <= %d',
+ 'log.epoch <= %d',
$this->epochMax);
}
+ if ($this->blockingHeraldRulePHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ '(event.rejectCode = %d AND event.rejectDetails IN (%Ls))',
+ PhabricatorRepositoryPushLog::REJECT_HERALD,
+ $this->blockingHeraldRulePHIDs);
+ }
+
return $where;
}
+ protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
+ $joins = parent::buildJoinClauseParts($conn);
+
+ if ($this->shouldJoinPushEventTable()) {
+ $joins[] = qsprintf(
+ $conn,
+ 'JOIN %T event ON event.phid = log.pushEventPHID',
+ id(new PhabricatorRepositoryPushEvent())->getTableName());
+ }
+
+ return $joins;
+ }
+
+ private function shouldJoinPushEventTable() {
+ if ($this->blockingHeraldRulePHIDs !== null) {
+ return true;
+ }
+
+ return false;
+ }
+
public function getQueryApplicationClass() {
return 'PhabricatorDiffusionApplication';
}
+ protected function getPrimaryTableAlias() {
+ return 'log';
+ }
+
+
}
diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
--- a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
+++ b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
@@ -32,6 +32,10 @@
$map['createdEnd']);
}
+ if ($map['blockingHeraldRulePHIDs']) {
+ $query->withBlockingHeraldRulePHIDs($map['blockingHeraldRulePHIDs']);
+ }
+
return $query;
}
@@ -43,13 +47,19 @@
->setAliases(array('repository', 'repositories', 'repositoryPHID'))
->setLabel(pht('Repositories'))
->setDescription(
- pht('Search for pull logs for specific repositories.')),
+ pht('Search for push logs for specific repositories.')),
id(new PhabricatorUsersSearchField())
->setKey('pusherPHIDs')
->setAliases(array('pusher', 'pushers', 'pusherPHID'))
->setLabel(pht('Pushers'))
->setDescription(
- pht('Search for pull logs by specific users.')),
+ pht('Search for push logs by specific users.')),
+ id(new PhabricatorSearchDatasourceField())
+ ->setDatasource(new HeraldRuleDatasource())
+ ->setKey('blockingHeraldRulePHIDs')
+ ->setLabel(pht('Blocked By'))
+ ->setDescription(
+ pht('Search for pushes blocked by particular Herald rules.')),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created After'))
->setKey('createdStart'),
diff --git a/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php b/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
--- a/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
@@ -49,6 +49,9 @@
'key_identifier' => array(
'columns' => array('requestIdentifier'),
),
+ 'key_reject' => array(
+ 'columns' => array('rejectCode', 'rejectDetails'),
+ ),
),
) + parent::getConfiguration();
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 15, 7:39 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7686764
Default Alt Text
D19556.diff (5 KB)

Event Timeline