@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.

Allow push events to be filtered by which Herald rule blocked the push

Summary: Depends on D19555. Ref T13164. See PHI765. An install is interested in getting a sense of the impact of a particular blocking rule, which seems reasonable. Support filtering for pushes blocked by a particular rule or set of rules.

Test Plan: {F5776385}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13164

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

+64 -11
+49 -9
src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
··· 12 12 private $pushEventPHIDs; 13 13 private $epochMin; 14 14 private $epochMax; 15 + private $blockingHeraldRulePHIDs; 15 16 16 17 public function withIDs(array $ids) { 17 18 $this->ids = $ids; ··· 54 55 return $this; 55 56 } 56 57 58 + public function withBlockingHeraldRulePHIDs(array $phids) { 59 + $this->blockingHeraldRulePHIDs = $phids; 60 + return $this; 61 + } 62 + 57 63 public function newResultObject() { 58 64 return new PhabricatorRepositoryPushLog(); 59 65 } ··· 89 95 if ($this->ids !== null) { 90 96 $where[] = qsprintf( 91 97 $conn, 92 - 'id IN (%Ld)', 98 + 'log.id IN (%Ld)', 93 99 $this->ids); 94 100 } 95 101 96 102 if ($this->phids !== null) { 97 103 $where[] = qsprintf( 98 104 $conn, 99 - 'phid IN (%Ls)', 105 + 'log.phid IN (%Ls)', 100 106 $this->phids); 101 107 } 102 108 103 109 if ($this->repositoryPHIDs !== null) { 104 110 $where[] = qsprintf( 105 111 $conn, 106 - 'repositoryPHID IN (%Ls)', 112 + 'log.repositoryPHID IN (%Ls)', 107 113 $this->repositoryPHIDs); 108 114 } 109 115 110 116 if ($this->pusherPHIDs !== null) { 111 117 $where[] = qsprintf( 112 118 $conn, 113 - 'pusherPHID in (%Ls)', 119 + 'log.pusherPHID in (%Ls)', 114 120 $this->pusherPHIDs); 115 121 } 116 122 117 123 if ($this->pushEventPHIDs !== null) { 118 124 $where[] = qsprintf( 119 125 $conn, 120 - 'pushEventPHID in (%Ls)', 126 + 'log.pushEventPHID in (%Ls)', 121 127 $this->pushEventPHIDs); 122 128 } 123 129 124 130 if ($this->refTypes !== null) { 125 131 $where[] = qsprintf( 126 132 $conn, 127 - 'refType IN (%Ls)', 133 + 'log.refType IN (%Ls)', 128 134 $this->refTypes); 129 135 } 130 136 131 137 if ($this->newRefs !== null) { 132 138 $where[] = qsprintf( 133 139 $conn, 134 - 'refNew IN (%Ls)', 140 + 'log.refNew IN (%Ls)', 135 141 $this->newRefs); 136 142 } 137 143 138 144 if ($this->epochMin !== null) { 139 145 $where[] = qsprintf( 140 146 $conn, 141 - 'epoch >= %d', 147 + 'log.epoch >= %d', 142 148 $this->epochMin); 143 149 } 144 150 145 151 if ($this->epochMax !== null) { 146 152 $where[] = qsprintf( 147 153 $conn, 148 - 'epoch <= %d', 154 + 'log.epoch <= %d', 149 155 $this->epochMax); 150 156 } 151 157 158 + if ($this->blockingHeraldRulePHIDs !== null) { 159 + $where[] = qsprintf( 160 + $conn, 161 + '(event.rejectCode = %d AND event.rejectDetails IN (%Ls))', 162 + PhabricatorRepositoryPushLog::REJECT_HERALD, 163 + $this->blockingHeraldRulePHIDs); 164 + } 165 + 152 166 return $where; 153 167 } 154 168 169 + protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { 170 + $joins = parent::buildJoinClauseParts($conn); 171 + 172 + if ($this->shouldJoinPushEventTable()) { 173 + $joins[] = qsprintf( 174 + $conn, 175 + 'JOIN %T event ON event.phid = log.pushEventPHID', 176 + id(new PhabricatorRepositoryPushEvent())->getTableName()); 177 + } 178 + 179 + return $joins; 180 + } 181 + 182 + private function shouldJoinPushEventTable() { 183 + if ($this->blockingHeraldRulePHIDs !== null) { 184 + return true; 185 + } 186 + 187 + return false; 188 + } 189 + 155 190 public function getQueryApplicationClass() { 156 191 return 'PhabricatorDiffusionApplication'; 157 192 } 193 + 194 + protected function getPrimaryTableAlias() { 195 + return 'log'; 196 + } 197 + 158 198 159 199 }
+12 -2
src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
··· 32 32 $map['createdEnd']); 33 33 } 34 34 35 + if ($map['blockingHeraldRulePHIDs']) { 36 + $query->withBlockingHeraldRulePHIDs($map['blockingHeraldRulePHIDs']); 37 + } 38 + 35 39 return $query; 36 40 } 37 41 ··· 43 47 ->setAliases(array('repository', 'repositories', 'repositoryPHID')) 44 48 ->setLabel(pht('Repositories')) 45 49 ->setDescription( 46 - pht('Search for pull logs for specific repositories.')), 50 + pht('Search for push logs for specific repositories.')), 47 51 id(new PhabricatorUsersSearchField()) 48 52 ->setKey('pusherPHIDs') 49 53 ->setAliases(array('pusher', 'pushers', 'pusherPHID')) 50 54 ->setLabel(pht('Pushers')) 51 55 ->setDescription( 52 - pht('Search for pull logs by specific users.')), 56 + pht('Search for push logs by specific users.')), 57 + id(new PhabricatorSearchDatasourceField()) 58 + ->setDatasource(new HeraldRuleDatasource()) 59 + ->setKey('blockingHeraldRulePHIDs') 60 + ->setLabel(pht('Blocked By')) 61 + ->setDescription( 62 + pht('Search for pushes blocked by particular Herald rules.')), 53 63 id(new PhabricatorSearchDateField()) 54 64 ->setLabel(pht('Created After')) 55 65 ->setKey('createdStart'),
+3
src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
··· 49 49 'key_identifier' => array( 50 50 'columns' => array('requestIdentifier'), 51 51 ), 52 + 'key_reject' => array( 53 + 'columns' => array('rejectCode', 'rejectDetails'), 54 + ), 52 55 ), 53 56 ) + parent::getConfiguration(); 54 57 }