1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52: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) { foreach ($this->lintMessages as $message) {
$inline = id(new PhabricatorAuditInlineComment()) $inline = id(new PhabricatorAuditInlineComment())
->setID($message['id'])
->setSyntheticAuthor( ->setSyntheticAuthor(
ArcanistLintSeverity::getStringForSeverity($message['severity']). ArcanistLintSeverity::getStringForSeverity($message['severity']).
' '.$message['code'].' ('.$message['name'].')') ' '.$message['code'].' ('.$message['name'].')')

View file

@ -6,7 +6,7 @@ final class DiffusionLintController extends DiffusionController {
public function processRequest() { public function processRequest() {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
if ($this->getRequest()->getStr('lint')) { if ($this->getRequest()->getStr('lint') !== null) {
$controller = new DiffusionLintDetailsController($this->getRequest()); $controller = new DiffusionLintDetailsController($this->getRequest());
$controller->setDiffusionRequest($drequest); $controller->setDiffusionRequest($drequest);
return $this->delegateToController($controller); return $this->delegateToController($controller);
@ -49,14 +49,7 @@ final class DiffusionLintController extends DiffusionController {
'Name', 'Name',
'Example', 'Example',
)) ))
->setColumnClasses(array( ->setColumnClasses(array('n', 'n', '', 'pri', '', ''));
'n',
'n',
'',
'pri',
'',
'',
));
$content = array(); $content = array();
@ -67,8 +60,17 @@ final class DiffusionLintController extends DiffusionController {
'view' => 'lint', 'view' => 'lint',
)); ));
$link = hsprintf(
'<a href="%s">%s</a>',
$drequest->generateURI(array(
'action' => 'lint',
'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)
->appendChild($table); ->appendChild($table);
$nav = $this->buildSideNav('lint', false); $nav = $this->buildSideNav('lint', false);

View file

@ -8,7 +8,8 @@ final class DiffusionLintDetailsController extends DiffusionController {
$offset = $this->getRequest()->getInt('offset', 0); $offset = $this->getRequest()->getInt('offset', 0);
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
$messages = $this->loadLintMessages($limit, $offset); $branch = $drequest->loadBranch();
$messages = $this->loadLintMessages($branch, $limit, $offset);
$is_dir = (substr('/'.$drequest->getPath(), -1) == '/'); $is_dir = (substr('/'.$drequest->getPath(), -1) == '/');
$rows = array(); $rows = array();
@ -27,6 +28,7 @@ final class DiffusionLintDetailsController extends DiffusionController {
'action' => 'browse', 'action' => 'browse',
'path' => $message['path'], 'path' => $message['path'],
'line' => $message['line'], 'line' => $message['line'],
'commit' => $branch->getLintCommit(),
)), )),
$message['line']); $message['line']);
@ -35,7 +37,6 @@ final class DiffusionLintDetailsController extends DiffusionController {
$line, $line,
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity( phutil_escape_html(ArcanistLintSeverity::getStringForSeverity(
$message['severity'])), $message['severity'])),
phutil_escape_html($message['code']),
phutil_escape_html($message['name']), phutil_escape_html($message['name']),
phutil_escape_html($message['description']), phutil_escape_html($message['description']),
); );
@ -46,21 +47,11 @@ final class DiffusionLintDetailsController extends DiffusionController {
'Path', 'Path',
'Line', 'Line',
'Severity', 'Severity',
'Code',
'Name', 'Name',
'Example', 'Description',
)) ))
->setColumnClasses(array( ->setColumnClasses(array('', 'n', '', '', ''))
'', ->setColumnVisibility(array($is_dir));
'n',
'',
'pri',
'',
'',
))
->setColumnVisibility(array(
$is_dir,
));
$content = array(); $content = array();
@ -77,8 +68,20 @@ final class DiffusionLintDetailsController extends DiffusionController {
->setHasMorePages(count($messages) >= $limit) ->setHasMorePages(count($messages) >= $limit)
->setURI($this->getRequest()->getRequestURI(), 'offset'); ->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()) $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($table)
->appendChild($pager); ->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(); $drequest = $this->getDiffusionRequest();
$branch = $drequest->loadBranch();
if (!$branch) { if (!$branch) {
return array(); return array();
} }
$conn = $branch->establishConnection('r'); $conn = $branch->establishConnection('r');
$where = ''; $where = array();
if ($drequest->getPath() != '') { if ($drequest->getPath() != '') {
$is_dir = (substr($drequest->getPath(), -1) == '/'); $is_dir = (substr($drequest->getPath(), -1) == '/');
$where = qsprintf( $where[] = qsprintf(
$conn, $conn,
'AND path '.($is_dir ? 'LIKE %>' : '= %s'), 'path '.($is_dir ? 'LIKE %>' : '= %s'),
'/'.$drequest->getPath()); '/'.$drequest->getPath());
} }
if ($drequest->getLint() != '') {
$where[] = qsprintf(
$conn,
'code = %s',
$drequest->getLint());
}
return queryfx_all( return queryfx_all(
$conn, $conn,
'SELECT * 'SELECT *
FROM %T FROM %T
WHERE branchID = %d WHERE branchID = %d
AND code = %s AND %Q
%Q
ORDER BY path, code, line ORDER BY path, code, line
LIMIT %d OFFSET %d', LIMIT %d OFFSET %d',
PhabricatorRepository::TABLE_LINTMESSAGE, PhabricatorRepository::TABLE_LINTMESSAGE,
$branch->getID(), $branch->getID(),
$drequest->getLint(), implode(' AND ', $where),
$where,
$limit, $limit,
$offset); $offset);
} }

View file

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

View file

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