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

Search builds based on who kicked them off

Summary:
It's only natural for users to be interested their own builds. We are also building in support for other sources of builds, the only formally supported way to run a build right now is via Herald.

In our third party codebase, we designate an application as the "thing" that started builds which are scheduled and managed automatically by phabricator. I believe this is a common practice elsewhere in the codebase when you're at a loss for a real human identity and you need to apply some transactions.

Test Plan: Ran some builds manually and saw them show up under the list of things I've run. Looking up builds based on those that had been started by a herald rule.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

authored by

Mike Riley and committed by
yelirekim
4865dbdf cd8a9fd6

+124 -1
+4
src/__phutil_library_map__.php
··· 1106 1106 'HarbormasterBuildEngine' => 'applications/harbormaster/engine/HarbormasterBuildEngine.php', 1107 1107 'HarbormasterBuildFailureException' => 'applications/harbormaster/exception/HarbormasterBuildFailureException.php', 1108 1108 'HarbormasterBuildGraph' => 'applications/harbormaster/engine/HarbormasterBuildGraph.php', 1109 + 'HarbormasterBuildInitiatorDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildInitiatorDatasource.php', 1109 1110 'HarbormasterBuildLintMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php', 1110 1111 'HarbormasterBuildListController' => 'applications/harbormaster/controller/HarbormasterBuildListController.php', 1111 1112 'HarbormasterBuildLog' => 'applications/harbormaster/storage/build/HarbormasterBuildLog.php', ··· 1281 1282 'HeraldRepetitionPolicyConfig' => 'applications/herald/config/HeraldRepetitionPolicyConfig.php', 1282 1283 'HeraldRule' => 'applications/herald/storage/HeraldRule.php', 1283 1284 'HeraldRuleController' => 'applications/herald/controller/HeraldRuleController.php', 1285 + 'HeraldRuleDatasource' => 'applications/herald/typeahead/HeraldRuleDatasource.php', 1284 1286 'HeraldRuleEditor' => 'applications/herald/editor/HeraldRuleEditor.php', 1285 1287 'HeraldRuleListController' => 'applications/herald/controller/HeraldRuleListController.php', 1286 1288 'HeraldRulePHIDType' => 'applications/herald/phid/HeraldRulePHIDType.php', ··· 5651 5653 'HarbormasterBuildEngine' => 'Phobject', 5652 5654 'HarbormasterBuildFailureException' => 'Exception', 5653 5655 'HarbormasterBuildGraph' => 'AbstractDirectedGraph', 5656 + 'HarbormasterBuildInitiatorDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 5654 5657 'HarbormasterBuildLintMessage' => 'HarbormasterDAO', 5655 5658 'HarbormasterBuildListController' => 'HarbormasterController', 5656 5659 'HarbormasterBuildLog' => array( ··· 5865 5868 'PhabricatorSubscribableInterface', 5866 5869 ), 5867 5870 'HeraldRuleController' => 'HeraldController', 5871 + 'HeraldRuleDatasource' => 'PhabricatorTypeaheadDatasource', 5868 5872 'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor', 5869 5873 'HeraldRuleListController' => 'HeraldController', 5870 5874 'HeraldRulePHIDType' => 'PhabricatorPHIDType',
+13
src/applications/harbormaster/query/HarbormasterBuildQuery.php
··· 8 8 private $buildStatuses; 9 9 private $buildablePHIDs; 10 10 private $buildPlanPHIDs; 11 + private $initiatorPHIDs; 11 12 private $needBuildTargets; 12 13 13 14 public function withIDs(array $ids) { ··· 32 33 33 34 public function withBuildPlanPHIDs(array $build_plan_phids) { 34 35 $this->buildPlanPHIDs = $build_plan_phids; 36 + return $this; 37 + } 38 + 39 + public function withInitiatorPHIDs(array $initiator_phids) { 40 + $this->initiatorPHIDs = $initiator_phids; 35 41 return $this; 36 42 } 37 43 ··· 165 171 $conn, 166 172 'buildPlanPHID IN (%Ls)', 167 173 $this->buildPlanPHIDs); 174 + } 175 + 176 + if ($this->initiatorPHIDs !== null) { 177 + $where[] = qsprintf( 178 + $conn, 179 + 'initiatorPHID IN (%Ls)', 180 + $this->initiatorPHIDs); 168 181 } 169 182 170 183 return $where;
+16
src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php
··· 31 31 ->setDescription( 32 32 pht('Search for builds with given statuses.')) 33 33 ->setDatasource(new HarbormasterBuildStatusDatasource()), 34 + id(new PhabricatorSearchDatasourceField()) 35 + ->setLabel(pht('Initiators')) 36 + ->setKey('initiators') 37 + ->setAliases(array('initiator')) 38 + ->setDescription( 39 + pht( 40 + 'Search for builds started by someone or something in particular.')) 41 + ->setDatasource(new HarbormasterBuildInitiatorDatasource()), 34 42 ); 35 43 } 36 44 ··· 45 53 $query->withBuildStatuses($map['statuses']); 46 54 } 47 55 56 + if ($map['initiators']) { 57 + $query->withInitiatorPHIDs($map['initiators']); 58 + } 59 + 48 60 return $query; 49 61 } 50 62 ··· 54 66 55 67 protected function getBuiltinQueryNames() { 56 68 return array( 69 + 'initiated' => pht('My Builds'), 57 70 'all' => pht('All Builds'), 58 71 'waiting' => pht('Waiting'), 59 72 'active' => pht('Active'), ··· 66 79 $query->setQueryKey($query_key); 67 80 68 81 switch ($query_key) { 82 + case 'initiated': 83 + $viewer = $this->requireViewer(); 84 + return $query->setParameter('initiators', array($viewer->getPHID())); 69 85 case 'all': 70 86 return $query; 71 87 case 'waiting':
+3
src/applications/harbormaster/storage/build/HarbormasterBuild.php
··· 59 59 'columns' => array('buildablePHID', 'planAutoKey'), 60 60 'unique' => true, 61 61 ), 62 + 'key_initiator' => array( 63 + 'columns' => array('initiatorPHID'), 64 + ), 62 65 ), 63 66 ) + parent::getConfiguration(); 64 67 }
+22
src/applications/harbormaster/typeahead/HarbormasterBuildInitiatorDatasource.php
··· 1 + <?php 2 + 3 + final class HarbormasterBuildInitiatorDatasource 4 + extends PhabricatorTypeaheadCompositeDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Build Initiators'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + return pht('Type the name of a user, application or Herald rule...'); 12 + } 13 + 14 + public function getComponentDatasources() { 15 + return array( 16 + new PhabricatorApplicationDatasource(), 17 + new PhabricatorPeopleUserFunctionDatasource(), 18 + new HeraldRuleDatasource(), 19 + ); 20 + } 21 + 22 + }
+13
src/applications/herald/query/HeraldRuleQuery.php
··· 8 8 private $ruleTypes; 9 9 private $contentTypes; 10 10 private $disabled; 11 + private $datasourceQuery; 11 12 private $triggerObjectPHIDs; 12 13 13 14 private $needConditionsAndActions; ··· 46 47 47 48 public function withDisabled($disabled) { 48 49 $this->disabled = $disabled; 50 + return $this; 51 + } 52 + 53 + public function withDatasourceQuery($query) { 54 + $this->datasourceQuery = $query; 49 55 return $this; 50 56 } 51 57 ··· 217 223 $conn_r, 218 224 'rule.isDisabled = %d', 219 225 (int)$this->disabled); 226 + } 227 + 228 + if ($this->datasourceQuery) { 229 + $where[] = qsprintf( 230 + $conn_r, 231 + 'rule.name LIKE %>', 232 + $this->datasourceQuery); 220 233 } 221 234 222 235 if ($this->triggerObjectPHIDs) {
+4 -1
src/applications/herald/storage/HeraldRule.php
··· 34 34 return array( 35 35 self::CONFIG_AUX_PHID => true, 36 36 self::CONFIG_COLUMN_SCHEMA => array( 37 - 'name' => 'text255', 37 + 'name' => 'sort255', 38 38 'contentType' => 'text255', 39 39 'mustMatchAll' => 'bool', 40 40 'configVersion' => 'uint32', ··· 47 47 'repetitionPolicy' => 'uint32?', 48 48 ), 49 49 self::CONFIG_KEY_SCHEMA => array( 50 + 'key_name' => array( 51 + 'columns' => array('name(128)'), 52 + ), 50 53 'key_author' => array( 51 54 'columns' => array('authorPHID'), 52 55 ),
+49
src/applications/herald/typeahead/HeraldRuleDatasource.php
··· 1 + <?php 2 + 3 + final class HeraldRuleDatasource 4 + extends PhabricatorTypeaheadDatasource { 5 + 6 + public function getPlaceholderText() { 7 + return pht('Type a Herald rule name...'); 8 + } 9 + 10 + public function getBrowseTitle() { 11 + return pht('Browse Herald Rules'); 12 + } 13 + 14 + public function getDatasourceApplicationClass() { 15 + return 'PhabricatorHeraldApplication'; 16 + } 17 + 18 + public function loadResults() { 19 + $viewer = $this->getViewer(); 20 + $raw_query = $this->getRawQuery(); 21 + 22 + $rules = id(new HeraldRuleQuery()) 23 + ->setViewer($viewer) 24 + ->withDatasourceQuery($raw_query) 25 + ->execute(); 26 + 27 + $handles = id(new PhabricatorHandleQuery()) 28 + ->setViewer($viewer) 29 + ->withPHIDs(mpull($rules, 'getPHID')) 30 + ->execute(); 31 + 32 + $results = array(); 33 + foreach ($rules as $rule) { 34 + $handle = $handles[$rule->getPHID()]; 35 + 36 + $result = id(new PhabricatorTypeaheadResult()) 37 + ->setName($handle->getFullName()) 38 + ->setPHID($handle->getPHID()); 39 + 40 + if ($rule->getIsDisabled()) { 41 + $result->setClosed(pht('Archived')); 42 + } 43 + 44 + $results[] = $result; 45 + } 46 + 47 + return $results; 48 + } 49 + }