1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Fix Diffusion lint counts under SVN

Summary: Also remove some columns.

Test Plan: Looked at SVN dir in Diffusion.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, vsuba

Maniphest Tasks: T2038

Differential Revision: https://secure.phabricator.com/D3949
This commit is contained in:
vrana 2012-11-09 17:45:19 -08:00
parent ef8c43ac2a
commit f47c0a3a06
5 changed files with 51 additions and 37 deletions

View file

@ -573,6 +573,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
foreach ($this->lintMessages as $message) {
$inline = id(new PhabricatorAuditInlineComment())
->setID($message['id'])
->setSyntheticAuthor(
ArcanistLintSeverity::getStringForSeverity($message['severity']).
' '.$message['code'].' ('.$message['name'].')')

View file

@ -6,7 +6,7 @@ final class DiffusionLintController extends DiffusionController {
public function processRequest() {
$drequest = $this->getDiffusionRequest();
if ($this->getRequest()->getStr('lint')) {
if ($this->getRequest()->getStr('lint') !== null) {
$controller = new DiffusionLintDetailsController($this->getRequest());
$controller->setDiffusionRequest($drequest);
return $this->delegateToController($controller);
@ -49,14 +49,7 @@ final class DiffusionLintController extends DiffusionController {
'Name',
'Example',
))
->setColumnClasses(array(
'n',
'n',
'',
'pri',
'',
'',
));
->setColumnClasses(array('n', 'n', '', 'pri', '', ''));
$content = array();
@ -67,8 +60,17 @@ final class DiffusionLintController extends DiffusionController {
'view' => 'lint',
));
$link = hsprintf(
'<a href="%s">%s</a>',
$drequest->generateURI(array(
'action' => 'lint',
'lint' => '',
)),
pht('Switch to List View'));
$content[] = id(new AphrontPanelView())
->setHeader(pht('%d Lint Message(s)', array_sum(ipull($codes, 'n'))))
->setCaption($link)
->appendChild($table);
$nav = $this->buildSideNav('lint', false);

View file

@ -8,7 +8,8 @@ final class DiffusionLintDetailsController extends DiffusionController {
$offset = $this->getRequest()->getInt('offset', 0);
$drequest = $this->getDiffusionRequest();
$messages = $this->loadLintMessages($limit, $offset);
$branch = $drequest->loadBranch();
$messages = $this->loadLintMessages($branch, $limit, $offset);
$is_dir = (substr('/'.$drequest->getPath(), -1) == '/');
$rows = array();
@ -27,6 +28,7 @@ final class DiffusionLintDetailsController extends DiffusionController {
'action' => 'browse',
'path' => $message['path'],
'line' => $message['line'],
'commit' => $branch->getLintCommit(),
)),
$message['line']);
@ -35,7 +37,6 @@ final class DiffusionLintDetailsController extends DiffusionController {
$line,
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity(
$message['severity'])),
phutil_escape_html($message['code']),
phutil_escape_html($message['name']),
phutil_escape_html($message['description']),
);
@ -46,21 +47,11 @@ final class DiffusionLintDetailsController extends DiffusionController {
'Path',
'Line',
'Severity',
'Code',
'Name',
'Example',
'Description',
))
->setColumnClasses(array(
'',
'n',
'',
'pri',
'',
'',
))
->setColumnVisibility(array(
$is_dir,
));
->setColumnClasses(array('', 'n', '', '', ''))
->setColumnVisibility(array($is_dir));
$content = array();
@ -77,8 +68,20 @@ final class DiffusionLintDetailsController extends DiffusionController {
->setHasMorePages(count($messages) >= $limit)
->setURI($this->getRequest()->getRequestURI(), 'offset');
$lint = $drequest->getLint();
$link = hsprintf(
'<a href="%s">%s</a>',
$drequest->generateURI(array(
'action' => 'lint',
'lint' => null,
)),
pht('Switch to Grouped View'));
$content[] = id(new AphrontPanelView())
->setHeader(pht('%d Lint Message(s)', count($messages)))
->setHeader(
($lint != '' ? phutil_escape_html($lint)." \xC2\xB7 " : '').
pht('%d Lint Message(s)', count($messages)))
->setCaption($link)
->appendChild($table)
->appendChild($pager);
@ -93,37 +96,45 @@ final class DiffusionLintDetailsController extends DiffusionController {
)));
}
private function loadLintMessages($limit, $offset) {
private function loadLintMessages(
PhabricatorRepositoryBranch $branch,
$limit,
$offset) {
$drequest = $this->getDiffusionRequest();
$branch = $drequest->loadBranch();
if (!$branch) {
return array();
}
$conn = $branch->establishConnection('r');
$where = '';
$where = array();
if ($drequest->getPath() != '') {
$is_dir = (substr($drequest->getPath(), -1) == '/');
$where = qsprintf(
$where[] = qsprintf(
$conn,
'AND path '.($is_dir ? 'LIKE %>' : '= %s'),
'path '.($is_dir ? 'LIKE %>' : '= %s'),
'/'.$drequest->getPath());
}
if ($drequest->getLint() != '') {
$where[] = qsprintf(
$conn,
'code = %s',
$drequest->getLint());
}
return queryfx_all(
$conn,
'SELECT *
FROM %T
WHERE branchID = %d
AND code = %s
%Q
AND %Q
ORDER BY path, code, line
LIMIT %d OFFSET %d',
PhabricatorRepository::TABLE_LINTMESSAGE,
$branch->getID(),
$drequest->getLint(),
$where,
implode(' AND ', $where),
$limit,
$offset);
}

View file

@ -317,7 +317,7 @@ abstract class DiffusionRequest {
'path' => $this->getPath(),
'branch' => $this->getBranch(),
'commit' => $default_commit,
'lint' => $this->getLint(),
'lint' => idx($params, 'lint', $this->getLint()),
);
foreach ($defaults as $key => $val) {
if (!isset($params[$key])) { // Overwrite NULL.

View file

@ -85,7 +85,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
'<a href="%s">%s</a>',
$drequest->generateURI(array(
'action' => 'lint',
'lint' => '',
'lint' => null,
)),
number_format($lint));
}
@ -174,7 +174,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
$commit = $path->getLastModifiedCommit();
if ($commit) {
$drequest = clone $request;
$drequest->setPath($path->getPath().$dir_slash);
$drequest->setPath($request->getPath().$path->getPath().$dir_slash);
$dict = self::renderLastModifiedColumns(
$drequest,
$this->handles,