mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 01:48:23 +01:00
Display number of lint messages in Diffusion dir
Test Plan: Went to https://secure.phabricator.com/diffusion/ARC/browse/. Saw number of lint messages per dir, not terribly slow. Went to https://secure.phabricator.com/diffusion/ARC/browse/master/src/difference/. Saw number of lint messages per file. Disabled lint, didn't see it. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3921
This commit is contained in:
parent
47a184e2a5
commit
846a359d9a
4 changed files with 76 additions and 6 deletions
|
@ -70,7 +70,19 @@ final class DiffusionHomeController extends DiffusionController {
|
|||
}
|
||||
}
|
||||
|
||||
$branch = new PhabricatorRepositoryBranch();
|
||||
$lint_messages = queryfx_all(
|
||||
$branch->establishConnection('r'),
|
||||
'SELECT b.repositoryID, b.name, COUNT(lm.id) AS n
|
||||
FROM %T b
|
||||
LEFT JOIN %T lm ON b.id = lm.branchID
|
||||
GROUP BY b.id',
|
||||
$branch->getTableName(),
|
||||
PhabricatorRepository::TABLE_LINTMESSAGE);
|
||||
$lint_messages = igroup($lint_messages, 'repositoryID');
|
||||
|
||||
$rows = array();
|
||||
$show_lint = false;
|
||||
foreach ($repositories as $repository) {
|
||||
$id = $repository->getID();
|
||||
$commit = idx($commits, $id);
|
||||
|
@ -86,6 +98,13 @@ final class DiffusionHomeController extends DiffusionController {
|
|||
number_format($size));
|
||||
}
|
||||
|
||||
$lint_branches = ipull(idx($lint_messages, $id, array()), 'n', 'name');
|
||||
$branch = $repository->getDefaultArcanistBranch();
|
||||
|
||||
if (isset($lint_branches[$branch])) {
|
||||
$show_lint = true;
|
||||
}
|
||||
|
||||
$date = '-';
|
||||
$time = '-';
|
||||
if ($commit) {
|
||||
|
@ -104,6 +123,9 @@ final class DiffusionHomeController extends DiffusionController {
|
|||
PhabricatorRepositoryType::getNameForRepositoryType(
|
||||
$repository->getVersionControlSystem()),
|
||||
$size,
|
||||
(isset($lint_branches[$branch])
|
||||
? $lint_branches[$branch]
|
||||
: ''),
|
||||
$commit
|
||||
? DiffusionView::linkCommit(
|
||||
$repository,
|
||||
|
@ -138,6 +160,7 @@ final class DiffusionHomeController extends DiffusionController {
|
|||
'Description',
|
||||
'VCS',
|
||||
'Commits',
|
||||
'Lint',
|
||||
'Last',
|
||||
'Date',
|
||||
'Time',
|
||||
|
@ -149,9 +172,21 @@ final class DiffusionHomeController extends DiffusionController {
|
|||
'',
|
||||
'n',
|
||||
'n',
|
||||
'n',
|
||||
'',
|
||||
'right',
|
||||
));
|
||||
$table->setColumnVisibility(
|
||||
array(
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
$show_lint,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Browse Repositories');
|
||||
|
|
|
@ -24,7 +24,7 @@ final class DiffusionLastModifiedController extends DiffusionController {
|
|||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$output = DiffusionBrowseTableView::renderLastModifiedColumns(
|
||||
$drequest->getRepository(),
|
||||
$drequest,
|
||||
$handles,
|
||||
$commit,
|
||||
$commit_data);
|
||||
|
|
|
@ -24,7 +24,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
}
|
||||
|
||||
public static function renderLastModifiedColumns(
|
||||
PhabricatorRepository $repository,
|
||||
DiffusionRequest $drequest,
|
||||
array $handles,
|
||||
PhabricatorRepositoryCommit $commit = null,
|
||||
PhabricatorRepositoryCommitData $data = null) {
|
||||
|
@ -33,7 +33,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
if ($commit) {
|
||||
$epoch = $commit->getEpoch();
|
||||
$modified = DiffusionView::linkCommit(
|
||||
$repository,
|
||||
$drequest->getRepository(),
|
||||
$commit->getCommitIdentifier());
|
||||
$date = date('M j, Y', $epoch);
|
||||
$time = date('g:i A', $epoch);
|
||||
|
@ -71,13 +71,34 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
$details = '';
|
||||
}
|
||||
|
||||
return array(
|
||||
$return = array(
|
||||
'commit' => $modified,
|
||||
'date' => $date,
|
||||
'time' => $time,
|
||||
'author' => $author,
|
||||
'details' => $details,
|
||||
);
|
||||
|
||||
$lint = self::loadLintMessagesCount($drequest);
|
||||
if ($lint !== null) {
|
||||
$return['lint'] = (string)$lint;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
private static function loadLintMessagesCount(DiffusionRequest $drequest) {
|
||||
$branch = $drequest->loadBranch();
|
||||
if (!$branch) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$like = (substr($drequest->getPath(), -1) == '/' ? 'LIKE %>' : '= %s');
|
||||
return head(queryfx_one(
|
||||
$drequest->getRepository()->establishConnection('r'),
|
||||
'SELECT COUNT(*) FROM %T WHERE branchID = %d AND path '.$like,
|
||||
PhabricatorRepository::TABLE_LINTMESSAGE,
|
||||
$branch->getID(),
|
||||
'/'.$drequest->getPath()));
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
@ -134,13 +155,16 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
|
||||
$commit = $path->getLastModifiedCommit();
|
||||
if ($commit) {
|
||||
$drequest = clone $request;
|
||||
$drequest->setPath($path->getPath().$dir_slash);
|
||||
$dict = self::renderLastModifiedColumns(
|
||||
$repository,
|
||||
$drequest,
|
||||
$this->handles,
|
||||
$commit,
|
||||
$path->getLastCommitData());
|
||||
} else {
|
||||
$dict = array(
|
||||
'lint' => celerity_generate_unique_node_id(),
|
||||
'commit' => celerity_generate_unique_node_id(),
|
||||
'date' => celerity_generate_unique_node_id(),
|
||||
'time' => celerity_generate_unique_node_id(),
|
||||
|
@ -151,7 +175,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
$uri = (string)$request->generateURI(
|
||||
array(
|
||||
'action' => 'lastmodified',
|
||||
'path' => $base_path.$path->getPath(),
|
||||
'path' => $base_path.$path->getPath().$dir_slash,
|
||||
));
|
||||
|
||||
$need_pull[$uri] = $dict;
|
||||
|
@ -181,6 +205,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
$this->linkHistory($base_path.$path->getPath().$dir_slash),
|
||||
$editor_button,
|
||||
$browse_link,
|
||||
$dict['lint'],
|
||||
$dict['commit'],
|
||||
$dict['date'],
|
||||
$dict['time'],
|
||||
|
@ -193,12 +218,16 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
Javelin::initBehavior('diffusion-pull-lastmodified', $need_pull);
|
||||
}
|
||||
|
||||
$branch = $this->getDiffusionRequest()->loadBranch();
|
||||
$show_lint = ($branch && $branch->getLintCommit());
|
||||
|
||||
$view = new AphrontTableView($rows);
|
||||
$view->setHeaders(
|
||||
array(
|
||||
'History',
|
||||
'Edit',
|
||||
'Path',
|
||||
'Lint',
|
||||
'Modified',
|
||||
'Date',
|
||||
'Time',
|
||||
|
@ -210,6 +239,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
'n',
|
||||
'',
|
||||
'',
|
||||
'right',
|
||||
|
@ -221,6 +251,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
true,
|
||||
$show_edit,
|
||||
true,
|
||||
$show_lint,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
|
|
|
@ -287,6 +287,10 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
|||
return idx($default_branches, $this->getVersionControlSystem());
|
||||
}
|
||||
|
||||
public function getDefaultArcanistBranch() {
|
||||
return coalesce($this->getDefaultBranch(), 'svn');
|
||||
}
|
||||
|
||||
private function isBranchInFilter($branch, $filter_key) {
|
||||
$vcs = $this->getVersionControlSystem();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue