@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 repository push logs to be filtered by pusher and repository

Summary: Ref T4195. Add UI options to filter push logs by pusher and repository. Add a link from the repository view page to the push logs.

Test Plan: Viewed a hosted repository, clicked logs link, saw logs. Filtered lgos by repo/pusher.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4195

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

+132
+12
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 399 399 ->setWorkflow(!$can_edit) 400 400 ->setDisabled(!$can_edit)); 401 401 402 + if ($repository->isHosted()) { 403 + $callsign = $repository->getCallsign(); 404 + $push_uri = $this->getApplicationURI( 405 + 'pushlog/?repositories=r'.$callsign); 406 + 407 + $view->addAction( 408 + id(new PhabricatorActionView()) 409 + ->setName(pht('View Push Logs')) 410 + ->setIcon('transcript') 411 + ->setHref($push_uri)); 412 + } 413 + 402 414 return $view; 403 415 } 404 416
+13
src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
··· 5 5 6 6 private $ids; 7 7 private $repositoryPHIDs; 8 + private $pusherPHIDs; 8 9 9 10 public function withIDs(array $ids) { 10 11 $this->ids = $ids; ··· 13 14 14 15 public function withRepositoryPHIDs(array $repository_phids) { 15 16 $this->repositoryPHIDs = $repository_phids; 17 + return $this; 18 + } 19 + 20 + public function withPusherPHIDs(array $pusher_phids) { 21 + $this->pusherPHIDs = $pusher_phids; 16 22 return $this; 17 23 } 18 24 ··· 71 77 $conn_r, 72 78 'repositoryPHID IN (%Ls)', 73 79 $this->repositoryPHIDs); 80 + } 81 + 82 + if ($this->pusherPHIDs) { 83 + $where[] = qsprintf( 84 + $conn_r, 85 + 'pusherPHID in (%Ls)', 86 + $this->pusherPHIDs); 74 87 } 75 88 76 89 $where[] = $this->buildPagingClause($conn_r);
+57
src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
··· 6 6 public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 7 $saved = new PhabricatorSavedQuery(); 8 8 9 + $saved->setParameter( 10 + 'repositoryPHIDs', 11 + $this->readPHIDsFromRequest( 12 + $request, 13 + 'repositories', 14 + array( 15 + PhabricatorRepositoryPHIDTypeRepository::TYPECONST, 16 + ))); 17 + 18 + $saved->setParameter( 19 + 'pusherPHIDs', 20 + $this->readUsersFromRequest( 21 + $request, 22 + 'pushers')); 23 + 9 24 return $saved; 10 25 } 11 26 12 27 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 13 28 $query = id(new PhabricatorRepositoryPushLogQuery()); 14 29 30 + $repository_phids = $saved->getParameter('repositoryPHIDs'); 31 + if ($repository_phids) { 32 + $query->withRepositoryPHIDs($repository_phids); 33 + } 34 + 35 + $pusher_phids = $saved->getParameter('pusherPHIDs'); 36 + if ($pusher_phids) { 37 + $query->withPusherPHIDs($pusher_phids); 38 + } 39 + 15 40 return $query; 16 41 } 17 42 ··· 19 44 AphrontFormView $form, 20 45 PhabricatorSavedQuery $saved_query) { 21 46 47 + $repository_phids = $saved_query->getParameter('repositoryPHIDs', array()); 48 + $pusher_phids = $saved_query->getParameter('pusherPHIDs', array()); 49 + 50 + $all_phids = array_merge( 51 + $repository_phids, 52 + $pusher_phids); 53 + 54 + if ($all_phids) { 55 + $handles = id(new PhabricatorHandleQuery()) 56 + ->setViewer($this->requireViewer()) 57 + ->withPHIDs($all_phids) 58 + ->execute(); 59 + } else { 60 + $handles = array(); 61 + } 62 + 63 + $repository_handles = array_select_keys($handles, $repository_phids); 64 + $pusher_handles = array_select_keys($handles, $pusher_phids); 65 + 66 + $form 67 + ->appendChild( 68 + id(new AphrontFormTokenizerControl()) 69 + ->setDatasource('/typeahead/common/repositories/') 70 + ->setName('repositories') 71 + ->setLabel(pht('Repositories')) 72 + ->setValue($repository_handles)) 73 + ->appendChild( 74 + id(new AphrontFormTokenizerControl()) 75 + ->setDatasource('/typeahead/common/accounts/') 76 + ->setName('pushers') 77 + ->setLabel(pht('Pushers')) 78 + ->setValue($pusher_handles)); 22 79 } 23 80 24 81 protected function getURI($path) {
+50
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 299 299 } 300 300 301 301 302 + /** 303 + * Read a list of generic PHIDs from a request in a flexible way. Like 304 + * @{method:readUsersFromRequest}, this method supports either array or 305 + * comma-delimited forms. Objects can be specified either by PHID or by 306 + * object name. 307 + * 308 + * @param AphrontRequest Request to read PHIDs from. 309 + * @param string Key to read in the request. 310 + * @param list<const> Optional, list of permitted PHID types. 311 + * @return list<phid> List of object PHIDs. 312 + * 313 + * @task read 314 + */ 315 + protected function readPHIDsFromRequest( 316 + AphrontRequest $request, 317 + $key, 318 + array $allow_types = array()) { 319 + 320 + $list = $request->getArr($key, null); 321 + if ($list === null) { 322 + $list = $request->getStrList($key); 323 + } 324 + 325 + if (!$list) { 326 + return array(); 327 + } 328 + 329 + $objects = id(new PhabricatorObjectQuery()) 330 + ->setViewer($this->requireViewer()) 331 + ->withNames($list) 332 + ->execute(); 333 + $list = mpull($objects, 'getPHID'); 334 + 335 + if (!$list) { 336 + return array(); 337 + } 338 + 339 + // If only certain PHID types are allowed, filter out all the others. 340 + if ($allow_types) { 341 + $allow_types = array_fuse($allow_types); 342 + foreach ($list as $key => $phid) { 343 + if (empty($allow_types[phid_get_type($phid)])) { 344 + unset($list[$key]); 345 + } 346 + } 347 + } 348 + 349 + return $list; 350 + } 351 + 302 352 protected function readBoolFromRequest( 303 353 AphrontRequest $request, 304 354 $key) {