mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
Display lint results for all repos
Summary: I want to add search per owner, this is a prerequisity for it. There's no link to this page yet, I didn't find a good place for it. Test Plan: Displayed it, clicked around. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, scottmac Maniphest Tasks: T2038 Differential Revision: https://secure.phabricator.com/D4067
This commit is contained in:
parent
d2568ac463
commit
8584b87df4
2 changed files with 69 additions and 34 deletions
|
@ -63,6 +63,7 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication {
|
||||||
),
|
),
|
||||||
'symbol/(?P<name>[^/]+)/' => 'DiffusionSymbolController',
|
'symbol/(?P<name>[^/]+)/' => 'DiffusionSymbolController',
|
||||||
'external/' => 'DiffusionExternalController',
|
'external/' => 'DiffusionExternalController',
|
||||||
|
'lint/' => 'DiffusionLintController',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
final class DiffusionLintController extends DiffusionController {
|
final class DiffusionLintController extends DiffusionController {
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->diffusionRequest;
|
||||||
|
|
||||||
if ($this->getRequest()->getStr('lint') !== null) {
|
if ($this->getRequest()->getStr('lint') !== null) {
|
||||||
$controller = new DiffusionLintDetailsController($this->getRequest());
|
$controller = new DiffusionLintDetailsController($this->getRequest());
|
||||||
|
@ -15,8 +15,30 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
$codes = $this->loadLintCodes();
|
$codes = $this->loadLintCodes();
|
||||||
$codes = array_reverse(isort($codes, 'n'));
|
$codes = array_reverse(isort($codes, 'n'));
|
||||||
|
|
||||||
|
if (!$drequest) {
|
||||||
|
$branches = id(new PhabricatorRepositoryBranch())->loadAllWhere(
|
||||||
|
'id IN (%Ld)',
|
||||||
|
array_unique(ipull($codes, 'branchID')));
|
||||||
|
|
||||||
|
$repositories = id(new PhabricatorRepository())->loadAllWhere(
|
||||||
|
'id IN (%Ld)',
|
||||||
|
array_unique(mpull($branches, 'getRepositoryID')));
|
||||||
|
|
||||||
|
$drequests = array();
|
||||||
|
foreach ($branches as $id => $branch) {
|
||||||
|
$drequests[$id] = DiffusionRequest::newFromDictionary(array(
|
||||||
|
'repository' => $repositories[$branch->getRepositoryID()],
|
||||||
|
'branch' => $branch->getName(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($codes as $code) {
|
foreach ($codes as $code) {
|
||||||
|
if (!$this->diffusionRequest) {
|
||||||
|
$drequest = $drequests[$code['branchID']];
|
||||||
|
}
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
hsprintf(
|
hsprintf(
|
||||||
'<a href="%s">%s</a>',
|
'<a href="%s">%s</a>',
|
||||||
|
@ -32,6 +54,10 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
'lint' => $code['code'],
|
'lint' => $code['code'],
|
||||||
)),
|
)),
|
||||||
$code['files']),
|
$code['files']),
|
||||||
|
hsprintf(
|
||||||
|
'<a href="%s">%s</a>',
|
||||||
|
$drequest->generateURI(array('action' => 'lint')),
|
||||||
|
$drequest->getCallsign()),
|
||||||
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity(
|
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity(
|
||||||
$code['maxSeverity'])),
|
$code['maxSeverity'])),
|
||||||
phutil_escape_html($code['code']),
|
phutil_escape_html($code['code']),
|
||||||
|
@ -44,12 +70,14 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
->setHeaders(array(
|
->setHeaders(array(
|
||||||
'Problems',
|
'Problems',
|
||||||
'Files',
|
'Files',
|
||||||
|
'Repository',
|
||||||
'Severity',
|
'Severity',
|
||||||
'Code',
|
'Code',
|
||||||
'Name',
|
'Name',
|
||||||
'Example',
|
'Example',
|
||||||
))
|
))
|
||||||
->setColumnClasses(array('n', 'n', '', 'pri', '', ''));
|
->setColumnVisibility(array(true, true, !$this->diffusionRequest))
|
||||||
|
->setColumnClasses(array('n', 'n', '', '', 'pri', '', ''));
|
||||||
|
|
||||||
$content = array();
|
$content = array();
|
||||||
|
|
||||||
|
@ -60,51 +88,59 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
'view' => 'lint',
|
'view' => 'lint',
|
||||||
));
|
));
|
||||||
|
|
||||||
$link = hsprintf(
|
$link = null;
|
||||||
'<a href="%s">%s</a>',
|
if ($this->diffusionRequest) {
|
||||||
$drequest->generateURI(array(
|
$link = hsprintf(
|
||||||
'action' => 'lint',
|
'<a href="%s">%s</a>',
|
||||||
'lint' => '',
|
$drequest->generateURI(array(
|
||||||
)),
|
'action' => 'lint',
|
||||||
pht('Switch to List View'));
|
'lint' => '',
|
||||||
|
)),
|
||||||
|
pht('Switch to List View'));
|
||||||
|
}
|
||||||
|
|
||||||
$content[] = id(new AphrontPanelView())
|
$content[] = id(new AphrontPanelView())
|
||||||
->setHeader(pht('%d Lint Message(s)', array_sum(ipull($codes, 'n'))))
|
->setHeader(pht('%d Lint Message(s)', array_sum(ipull($codes, 'n'))))
|
||||||
->setCaption($link)
|
->setCaption($link)
|
||||||
->appendChild($table);
|
->appendChild($table);
|
||||||
|
|
||||||
$nav = $this->buildSideNav('lint', false);
|
$title = array('Lint');
|
||||||
$nav->appendChild($content);
|
if ($this->diffusionRequest) {
|
||||||
|
$title[] = $drequest->getCallsign();
|
||||||
|
$content = $this->buildSideNav('lint', false)->appendChild($content);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$nav,
|
$content,
|
||||||
array('title' => array(
|
array('title' => $title));
|
||||||
'Lint',
|
|
||||||
$drequest->getRepository()->getCallsign(),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadLintCodes() {
|
private function loadLintCodes() {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->diffusionRequest;
|
||||||
$branch = $drequest->loadBranch();
|
$conn = id(new PhabricatorRepository())->establishConnection('r');
|
||||||
if (!$branch) {
|
$where = array('1 = 1');
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn = $branch->establishConnection('r');
|
if ($drequest) {
|
||||||
|
$branch = $drequest->loadBranch();
|
||||||
|
if (!$branch) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$where = '';
|
$where[] = qsprintf($conn, 'branchID = %d', $branch->getID());
|
||||||
if ($drequest->getPath() != '') {
|
|
||||||
$is_dir = (substr($drequest->getPath(), -1) == '/');
|
if ($drequest->getPath() != '') {
|
||||||
$where = qsprintf(
|
$is_dir = (substr($drequest->getPath(), -1) == '/');
|
||||||
$conn,
|
$where[] = qsprintf(
|
||||||
'AND path '.($is_dir ? 'LIKE %>' : '= %s'),
|
$conn,
|
||||||
'/'.$drequest->getPath());
|
'path '.($is_dir ? 'LIKE %>' : '= %s'),
|
||||||
|
'/'.$drequest->getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryfx_all(
|
return queryfx_all(
|
||||||
$conn,
|
$conn,
|
||||||
'SELECT
|
'SELECT
|
||||||
|
branchID,
|
||||||
code,
|
code,
|
||||||
MAX(severity) AS maxSeverity,
|
MAX(severity) AS maxSeverity,
|
||||||
MAX(name) AS maxName,
|
MAX(name) AS maxName,
|
||||||
|
@ -112,12 +148,10 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
COUNT(DISTINCT path) AS files,
|
COUNT(DISTINCT path) AS files,
|
||||||
COUNT(*) AS n
|
COUNT(*) AS n
|
||||||
FROM %T
|
FROM %T
|
||||||
WHERE branchID = %d
|
WHERE %Q
|
||||||
%Q
|
GROUP BY branchID, code',
|
||||||
GROUP BY code',
|
|
||||||
PhabricatorRepository::TABLE_LINTMESSAGE,
|
PhabricatorRepository::TABLE_LINTMESSAGE,
|
||||||
$branch->getID(),
|
implode(' AND ', $where));
|
||||||
$where);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue