From 75b11d6d7d2330c8530abab97149f54a8de5f016 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 10 Apr 2011 15:50:26 -0700 Subject: [PATCH] Lint and unit star support. Test plan: quack Differential Revision: 35 --- resources/sql/patches/025.commentopt.sql | 2 + ...PI_differential_setdiffproperty_Method.php | 2 +- .../DifferentialRevisionViewController.php | 109 ++++++++++++++---- .../controller/revisionview/__init__.php | 1 + .../diffproperty/DifferentialDiffProperty.php | 2 +- .../differential/revision-detail.css | 47 ++++++++ 6 files changed, 140 insertions(+), 23 deletions(-) create mode 100644 resources/sql/patches/025.commentopt.sql diff --git a/resources/sql/patches/025.commentopt.sql b/resources/sql/patches/025.commentopt.sql new file mode 100644 index 0000000000..7a8fe45681 --- /dev/null +++ b/resources/sql/patches/025.commentopt.sql @@ -0,0 +1,2 @@ +ALTER TABLE phabricator_differential.differential_inlinecomment + ADD KEY (revisionID, authorPHID); \ No newline at end of file diff --git a/src/applications/conduit/method/differential/setdiffproperty/ConduitAPI_differential_setdiffproperty_Method.php b/src/applications/conduit/method/differential/setdiffproperty/ConduitAPI_differential_setdiffproperty_Method.php index 5fa9d2db1e..07afed39d6 100644 --- a/src/applications/conduit/method/differential/setdiffproperty/ConduitAPI_differential_setdiffproperty_Method.php +++ b/src/applications/conduit/method/differential/setdiffproperty/ConduitAPI_differential_setdiffproperty_Method.php @@ -44,7 +44,7 @@ class ConduitAPI_differential_setdiffproperty_Method extends ConduitAPIMethod { $property = new DifferentialDiffProperty(); $property->setDiffID($request->getValue('diff_id')); $property->setName($request->getValue('name')); - $property->setData($request->getValue('data')); + $property->setData(json_decode($request->getValue('data'), true)); $property->save(); return; } diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index b8e3f683bf..2b90c45aea 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -110,10 +110,23 @@ class DifferentialRevisionViewController extends DifferentialController { $visible_changesets = $changesets; } + $diff_properties = id(new DifferentialDiffProperty())->loadAllWhere( + 'diffID = %d AND name IN (%Ls)', + $target->getID(), + array( + 'arc:lint', + 'arc:unit', + )); + $diff_properties = mpull($diff_properties, 'getData', 'getName'); + $revision_detail = new DifferentialRevisionDetailView(); $revision_detail->setRevision($revision); - $properties = $this->getRevisionProperties($revision, $target, $handles); + $properties = $this->getRevisionProperties( + $revision, + $target, + $handles, + $diff_properties); $revision_detail->setProperties($properties); $actions = $this->getRevisionActions($revision); @@ -201,7 +214,8 @@ class DifferentialRevisionViewController extends DifferentialController { private function getRevisionProperties( DifferentialRevision $revision, DifferentialDiff $diff, - array $handles) { + array $handles, + array $diff_properties) { $properties = array(); @@ -235,11 +249,81 @@ class DifferentialRevisionViewController extends DifferentialController { $lstar = DifferentialRevisionUpdateHistoryView::renderDiffLintStar($diff); $lmsg = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff); - $properties['Lint'] = $lstar.' '.$lmsg; + $ldata = idx($diff_properties, 'arc:lint'); + $ltail = null; + if ($ldata) { + $ldata = igroup($ldata, 'path'); + $lint_messages = array(); + foreach ($ldata as $path => $messages) { + $message_markup = array(); + foreach ($messages as $message) { + $path = idx($message, 'path'); + $line = idx($message, 'line'); + + $code = idx($message, 'code'); + $severity = idx($message, 'severity'); + + $name = idx($message, 'name'); + $description = idx($message, 'description'); + + $message_markup[] = + '
  • '. + ''. + phutil_escape_html(ucwords($severity)). + ''. + ' '. + '('.phutil_escape_html($code).') '. + phutil_escape_html($name). + ' at line '.phutil_escape_html($line). + '

    '.phutil_escape_html($description).'

    '. + '
  • '; + } + $lint_messages[] = + '
  • '. + 'Lint for '.phutil_escape_html($path).''. + ''. + '
  • '; + } + $ltail = + '
    '. + ''. + '
    '; + } + + $properties['Lint'] = $lstar.' '.$lmsg.$ltail; $ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff); $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff); - $properties['Unit'] = $ustar.' '.$umsg; + + $udata = idx($diff_properties, 'arc:unit'); + $utail = null; + if ($udata) { + $unit_messages = array(); + foreach ($udata as $test) { + $name = phutil_escape_html(idx($test, 'name')); + $result = phutil_escape_html(idx($test, 'result')); + $userdata = phutil_escape_html(idx($test, 'userdata')); + $unit_messages[] = + ''. + ''.$name.''. + ''. + strtoupper($result). + ''. + ''.$userdata.''. + ''; + } + + $utail = + '
    '. + ''. + implode("\n", $unit_messages). + '
    '. + '
    '; + } + + $properties['Unit'] = $ustar.' '.$umsg.$utail; $tasks = $revision->getAttachedPHIDs( PhabricatorPHIDConstants::PHID_TYPE_TASK); @@ -556,17 +640,6 @@ class DifferentialRevisionViewController extends DifferentialController { ; } - - $blast_uri = RedirectURI( - '/intern/differential/?action=blast&fbid='.$revision->getFBID()) - ->setTier('intern'); - $links[] = array( - 'blast', - Blast Revision, - ); - - - $engineering_repository_id = RepositoryRef::getByCallsign('E')->getID(); $svn_revision = $revision->getSVNRevision(); if ($status == DifferentialConstants::COMMITTED && @@ -580,12 +653,6 @@ class DifferentialRevisionViewController extends DifferentialController { ); } - $links[] = array( - 'herald-transcript', - getFBID()} - >Herald Transcripts, - ); - } diff --git a/src/applications/differential/controller/revisionview/__init__.php b/src/applications/differential/controller/revisionview/__init__.php index c6e009de3c..0d373f69c5 100644 --- a/src/applications/differential/controller/revisionview/__init__.php +++ b/src/applications/differential/controller/revisionview/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/revisi phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/storage/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/comment'); +phutil_require_module('phabricator', 'applications/differential/storage/diffproperty'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/storage/revision'); phutil_require_module('phabricator', 'applications/differential/view/addcomment'); diff --git a/src/applications/differential/storage/diffproperty/DifferentialDiffProperty.php b/src/applications/differential/storage/diffproperty/DifferentialDiffProperty.php index 07a09776c3..e70e95f9f6 100644 --- a/src/applications/differential/storage/diffproperty/DifferentialDiffProperty.php +++ b/src/applications/differential/storage/diffproperty/DifferentialDiffProperty.php @@ -25,7 +25,7 @@ class DifferentialDiffProperty extends DifferentialDAO { protected function getConfiguration() { return array( self::CONFIG_SERIALIZATION => array( - 'data' => self::SERIALIZATION_JSON, + 'data' => self::SERIALIZATION_JSON, )) + parent::getConfiguration(); } diff --git a/webroot/rsrc/css/application/differential/revision-detail.css b/webroot/rsrc/css/application/differential/revision-detail.css index 953742f17e..61c70ecc72 100644 --- a/webroot/rsrc/css/application/differential/revision-detail.css +++ b/webroot/rsrc/css/application/differential/revision-detail.css @@ -28,3 +28,50 @@ margin-right: 265px; } +.differential-unit-block, +.differential-lint-block { + padding: .5em; + background: #fcfcec; + margin: .5em 0; + font-size: 11px; + line-height: 1.5em; +} + +.differential-lint-block .lint-severity-warning { + background: #ffff66; + padding: 0 0.5em; + font-weight: bold; +} + +.differential-lint-block .lint-severity-error { + background: #ff3333; + padding: 0 0.5em; + font-weight: bold; +} + +.differential-lint-block .lint-file-block { +} + +.differential-lint-block li li { + margin-left: 1.5em; +} + +.differential-lint-block li li p { + margin-left: 1em; + color: #666666; +} + +.differential-unit-table th { + white-space: nowrap; + padding: 4px 8px; +} + +.differential-unit-table .result-fail { + background: #ff3333; +} + +.differential-unit-table td { + width: 100%; + padding: 4px 8px; + color: #666666; +}