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

Do author PHID lookups in Diffusion views.

+91 -6
+12
src/applications/diffusion/controller/history/DiffusionHistoryController.php
··· 31 31 $history_query->setLimit($page_size + 1); 32 32 $history = $history_query->loadHistory(); 33 33 34 + $phids = array(); 35 + foreach ($history as $item) { 36 + $data = $item->getCommitData(); 37 + if ($data) { 38 + if ($data->getCommitDetail('authorPHID')) { 39 + $phids[] = $data->getCommitDetail('authorPHID'); 40 + } 41 + } 42 + } 43 + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); 44 + 34 45 $pager = new AphrontPagerView(); 35 46 $pager->setPageSize($page_size); 36 47 $pager->setOffset($offset); ··· 53 64 54 65 $history_table = new DiffusionHistoryTableView(); 55 66 $history_table->setDiffusionRequest($drequest); 67 + $history_table->setHandles($handles); 56 68 $history_table->setHistory($history); 57 69 58 70 $history_panel = new AphrontPanelView();
+3
src/applications/diffusion/controller/history/__init__.php
··· 9 9 phutil_require_module('phabricator', 'applications/diffusion/controller/base'); 10 10 phutil_require_module('phabricator', 'applications/diffusion/query/history/base'); 11 11 phutil_require_module('phabricator', 'applications/diffusion/view/historytable'); 12 + phutil_require_module('phabricator', 'applications/phid/handle/data'); 12 13 phutil_require_module('phabricator', 'view/control/pager'); 13 14 phutil_require_module('phabricator', 'view/layout/panel'); 15 + 16 + phutil_require_module('phutil', 'utils'); 14 17 15 18 16 19 phutil_require_source('DiffusionHistoryController.php');
+8
src/applications/diffusion/controller/lastmodified/DiffusionLastModifiedController.php
··· 26 26 $drequest); 27 27 list($commit, $commit_data) = $modified_query->loadLastModification(); 28 28 29 + $phids = array(); 30 + if ($commit_data->getCommitDetail('authorPHID')) { 31 + $phids = array($commit_data->getCommitDetail('authorPHID')); 32 + } 33 + 34 + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); 35 + 29 36 $output = DiffusionBrowseTableView::renderLastModifiedColumns( 30 37 $drequest->getRepository(), 38 + $handles, 31 39 $commit, 32 40 $commit_data); 33 41
+1
src/applications/diffusion/controller/lastmodified/__init__.php
··· 10 10 phutil_require_module('phabricator', 'applications/diffusion/controller/base'); 11 11 phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base'); 12 12 phutil_require_module('phabricator', 'applications/diffusion/view/browsetable'); 13 + phutil_require_module('phabricator', 'applications/phid/handle/data'); 13 14 14 15 phutil_require_module('phutil', 'utils'); 15 16
+30 -4
src/applications/diffusion/controller/repository/DiffusionRepositoryController.php
··· 29 29 $history_query = DiffusionHistoryQuery::newFromDiffusionRequest( 30 30 $drequest); 31 31 $history_query->setLimit(15); 32 + $history = $history_query->loadHistory(); 32 33 33 - $history = $history_query->loadHistory(); 34 + $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); 35 + $browse_results = $browse_query->loadPaths(); 36 + 37 + $phids = array(); 38 + 39 + foreach ($history as $item) { 40 + $data = $item->getCommitData(); 41 + if ($data) { 42 + if ($data->getCommitDetail('authorPHID')) { 43 + $phids[$data->getCommitDetail('authorPHID')] = true; 44 + } 45 + } 46 + } 47 + 48 + foreach ($browse_results as $item) { 49 + $data = $item->getLastCommitData(); 50 + if ($data) { 51 + if ($data->getCommitDetail('authorPHID')) { 52 + $phids[$data->getCommitDetail('authorPHID')] = true; 53 + } 54 + } 55 + } 56 + 57 + $phids = array_keys($phids); 58 + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); 59 + 34 60 $history_table = new DiffusionHistoryTableView(); 35 61 $history_table->setDiffusionRequest($drequest); 62 + $history_table->setHandles($handles); 36 63 $history_table->setHistory($history); 37 64 38 65 $callsign = $drequest->getRepository()->getCallsign(); ··· 49 76 50 77 $content[] = $panel; 51 78 52 - $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); 53 - $results = $browse_query->loadPaths(); 54 79 55 80 $browse_table = new DiffusionBrowseTableView(); 56 81 $browse_table->setDiffusionRequest($drequest); 57 - $browse_table->setPaths($results); 82 + $browse_table->setHandles($handles); 83 + $browse_table->setPaths($browse_results); 58 84 59 85 $browse_panel = new AphrontPanelView(); 60 86 $browse_panel->setHeader('Browse Repository');
+2
src/applications/diffusion/controller/repository/__init__.php
··· 13 13 phutil_require_module('phabricator', 'applications/diffusion/view/branchtable'); 14 14 phutil_require_module('phabricator', 'applications/diffusion/view/browsetable'); 15 15 phutil_require_module('phabricator', 'applications/diffusion/view/historytable'); 16 + phutil_require_module('phabricator', 'applications/phid/handle/data'); 16 17 phutil_require_module('phabricator', 'view/layout/panel'); 17 18 18 19 phutil_require_module('phutil', 'markup'); 20 + phutil_require_module('phutil', 'utils'); 19 21 20 22 21 23 phutil_require_source('DiffusionRepositoryController.php');
+14 -1
src/applications/diffusion/view/browsetable/DiffusionBrowseTableView.php
··· 19 19 final class DiffusionBrowseTableView extends DiffusionView { 20 20 21 21 private $paths; 22 + private $handles = array(); 22 23 23 24 public function setPaths(array $paths) { 24 25 $this->paths = $paths; 25 26 return $this; 26 27 } 27 28 29 + public function setHandles(array $handles) { 30 + $this->handles = $handles; 31 + return $this; 32 + } 33 + 28 34 public static function renderLastModifiedColumns( 29 35 PhabricatorRepository $repository, 36 + array $handles, 30 37 PhabricatorRepositoryCommit $commit = null, 31 38 PhabricatorRepositoryCommitData $data = null) { 32 39 ··· 44 51 } 45 52 46 53 if ($data) { 47 - $author = phutil_escape_html($data->getAuthorName()); 54 + $author_phid = $data->getCommitDetail('authorPHID'); 55 + if ($author_phid && isset($handles[$author_phid])) { 56 + $author = $handles[$author_phid]->renderLink(); 57 + } else { 58 + $author = phutil_escape_html($data->getAuthorName()); 59 + } 48 60 $details = phutil_escape_html($data->getSummary()); 49 61 } else { 50 62 $author = ''; ··· 96 108 if ($commit) { 97 109 $dict = self::renderLastModifiedColumns( 98 110 $repository, 111 + $this->handles, 99 112 $commit, 100 113 $path->getLastCommitData()); 101 114 } else {
+21 -1
src/applications/diffusion/view/historytable/DiffusionHistoryTableView.php
··· 19 19 final class DiffusionHistoryTableView extends DiffusionView { 20 20 21 21 private $history; 22 + private $handles = array(); 22 23 23 24 public function setHistory(array $history) { 24 25 $this->history = $history; 26 + return $this; 27 + } 28 + 29 + public function setHandles(array $handles) { 30 + $this->handles = $handles; 25 31 return $this; 26 32 } 27 33 28 34 public function render() { 29 35 $drequest = $this->getDiffusionRequest(); 30 36 37 + $handles = $this->handles; 38 + 31 39 $rows = array(); 32 40 foreach ($this->history as $history) { 33 41 $epoch = $history->getEpoch(); ··· 40 48 $time = null; 41 49 } 42 50 51 + $data = $history->getCommitData(); 52 + $author_phid = null; 53 + if ($data) { 54 + $author_phid = $data->getCommitDetail('authorPHID'); 55 + } 56 + 57 + if ($author_phid && isset($handles[$author_phid])) { 58 + $author = $handles[$author_phid]->renderLink(); 59 + } else { 60 + $author = phutil_escape_html($history->getAuthorName()); 61 + } 62 + 43 63 $rows[] = array( 44 64 $this->linkBrowse( 45 65 $drequest->getPath(), ··· 54 74 $history->getFileType()), 55 75 $date, 56 76 $time, 57 - phutil_escape_html($history->getAuthorName()), 77 + $author, 58 78 phutil_escape_html($history->getSummary()), 59 79 // TODO: etc etc 60 80 );