diff --git a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php index f02f6026d0..bcbd372f75 100644 --- a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php +++ b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php @@ -1,79 +1,80 @@ [A-Z]+)(?P[a-z0-9]+)' => 'DiffusionCommitController', '/diffusion/' => array( '' => 'DiffusionHomeController', '(?P[A-Z]+)/' => array( '' => 'DiffusionRepositoryController', 'repository/(?P.*)' => 'DiffusionRepositoryController', 'change/(?P.*)' => 'DiffusionChangeController', 'history/(?P.*)' => 'DiffusionHistoryController', 'browse/(?P.*)' => 'DiffusionBrowseController', 'lastmodified/(?P.*)' => 'DiffusionLastModifiedController', 'diff/' => 'DiffusionDiffController', 'tags/(?P.*)' => 'DiffusionTagListController', 'branches/(?P.*)' => 'DiffusionBranchTableController', 'lint/(?P.*)' => 'DiffusionLintController', 'commit/(?P[a-z0-9]+)/branches/' => 'DiffusionCommitBranchesController', 'commit/(?P[a-z0-9]+)/tags/' => 'DiffusionCommitTagsController', 'commit/(?P[a-z0-9]+)/edit/' => 'DiffusionCommitEditController', ), 'inline/' => array( 'edit/(?P[^/]+)/' => 'DiffusionInlineCommentController', 'preview/(?P[^/]+)/' => 'DiffusionInlineCommentPreviewController', ), 'services/' => array( 'path/' => array( 'complete/' => 'DiffusionPathCompleteController', 'validate/' => 'DiffusionPathValidateController', ), ), 'symbol/(?P[^/]+)/' => 'DiffusionSymbolController', 'external/' => 'DiffusionExternalController', + 'lint/' => 'DiffusionLintController', ), ); } public function getApplicationGroup() { return self::GROUP_CORE; } public function getApplicationOrder() { return 0.120; } } diff --git a/src/applications/diffusion/controller/DiffusionLintController.php b/src/applications/diffusion/controller/DiffusionLintController.php index 81f6d50459..876947ffa1 100644 --- a/src/applications/diffusion/controller/DiffusionLintController.php +++ b/src/applications/diffusion/controller/DiffusionLintController.php @@ -1,123 +1,157 @@ getDiffusionRequest(); + $drequest = $this->diffusionRequest; if ($this->getRequest()->getStr('lint') !== null) { $controller = new DiffusionLintDetailsController($this->getRequest()); $controller->setDiffusionRequest($drequest); return $this->delegateToController($controller); } $codes = $this->loadLintCodes(); $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(); foreach ($codes as $code) { + if (!$this->diffusionRequest) { + $drequest = $drequests[$code['branchID']]; + } + $rows[] = array( hsprintf( '%s', $drequest->generateURI(array( 'action' => 'lint', 'lint' => $code['code'], )), $code['n']), hsprintf( '%s', $drequest->generateURI(array( 'action' => 'browse', 'lint' => $code['code'], )), $code['files']), + hsprintf( + '%s', + $drequest->generateURI(array('action' => 'lint')), + $drequest->getCallsign()), phutil_escape_html(ArcanistLintSeverity::getStringForSeverity( $code['maxSeverity'])), phutil_escape_html($code['code']), phutil_escape_html($code['maxName']), phutil_escape_html($code['maxDescription']), ); } $table = id(new AphrontTableView($rows)) ->setHeaders(array( 'Problems', 'Files', + 'Repository', 'Severity', 'Code', 'Name', 'Example', )) - ->setColumnClasses(array('n', 'n', '', 'pri', '', '')); + ->setColumnVisibility(array(true, true, !$this->diffusionRequest)) + ->setColumnClasses(array('n', 'n', '', '', 'pri', '', '')); $content = array(); $content[] = $this->buildCrumbs( array( 'branch' => true, 'path' => true, 'view' => 'lint', )); - $link = hsprintf( - '%s', - $drequest->generateURI(array( - 'action' => 'lint', - 'lint' => '', - )), - pht('Switch to List View')); + $link = null; + if ($this->diffusionRequest) { + $link = hsprintf( + '%s', + $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); - $nav->appendChild($content); + $title = array('Lint'); + if ($this->diffusionRequest) { + $title[] = $drequest->getCallsign(); + $content = $this->buildSideNav('lint', false)->appendChild($content); + } return $this->buildStandardPageResponse( - $nav, - array('title' => array( - 'Lint', - $drequest->getRepository()->getCallsign(), - ))); + $content, + array('title' => $title)); } private function loadLintCodes() { - $drequest = $this->getDiffusionRequest(); - $branch = $drequest->loadBranch(); - if (!$branch) { - return array(); - } - - $conn = $branch->establishConnection('r'); - - $where = ''; - if ($drequest->getPath() != '') { - $is_dir = (substr($drequest->getPath(), -1) == '/'); - $where = qsprintf( - $conn, - 'AND path '.($is_dir ? 'LIKE %>' : '= %s'), - '/'.$drequest->getPath()); + $drequest = $this->diffusionRequest; + $conn = id(new PhabricatorRepository())->establishConnection('r'); + $where = array('1 = 1'); + + if ($drequest) { + $branch = $drequest->loadBranch(); + if (!$branch) { + return array(); + } + + $where[] = qsprintf($conn, 'branchID = %d', $branch->getID()); + + if ($drequest->getPath() != '') { + $is_dir = (substr($drequest->getPath(), -1) == '/'); + $where[] = qsprintf( + $conn, + 'path '.($is_dir ? 'LIKE %>' : '= %s'), + '/'.$drequest->getPath()); + } } return queryfx_all( $conn, 'SELECT + branchID, code, MAX(severity) AS maxSeverity, MAX(name) AS maxName, MAX(description) AS maxDescription, COUNT(DISTINCT path) AS files, COUNT(*) AS n FROM %T - WHERE branchID = %d - %Q - GROUP BY code', + WHERE %Q + GROUP BY branchID, code', PhabricatorRepository::TABLE_LINTMESSAGE, - $branch->getID(), - $where); + implode(' AND ', $where)); } }