1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Lint and unit star support.

Test plan: quack

Differential Revision: 35
This commit is contained in:
epriestley 2011-04-10 15:50:26 -07:00
parent 689eb11ff3
commit 75b11d6d7d
6 changed files with 140 additions and 23 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE phabricator_differential.differential_inlinecomment
ADD KEY (revisionID, authorPHID);

View file

@ -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;
}

View file

@ -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[] =
'<li>'.
'<span class="lint-severity-'.phutil_escape_html($severity).'">'.
phutil_escape_html(ucwords($severity)).
'</span>'.
' '.
'('.phutil_escape_html($code).') '.
phutil_escape_html($name).
' at line '.phutil_escape_html($line).
'<p>'.phutil_escape_html($description).'</p>'.
'</li>';
}
$lint_messages[] =
'<li class="lint-file-block">'.
'Lint for <strong>'.phutil_escape_html($path).'</strong>'.
'<ul>'.implode("\n", $message_markup).'</ul>'.
'</li>';
}
$ltail =
'<div class="differential-lint-block">'.
'<ul>'.
implode("\n", $lint_messages).
'</ul>'.
'</div>';
}
$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[] =
'<tr>'.
'<th>'.$name.'</th>'.
'<th class="unit-test-result result-'.$result.'">'.
strtoupper($result).
'</th>'.
'<td>'.$userdata.'</td>'.
'</tr>';
}
$utail =
'<div class="differential-unit-block">'.
'<table class="differential-unit-table">'.
implode("\n", $unit_messages).
'</table>'.
'</div>';
}
$properties['Unit'] = $ustar.' '.$umsg.$utail;
$tasks = $revision->getAttachedPHIDs(
PhabricatorPHIDConstants::PHID_TYPE_TASK);
@ -556,17 +640,6 @@ class DifferentialRevisionViewController extends DifferentialController {
</tools:notice>;
}
$blast_uri = RedirectURI(
'/intern/differential/?action=blast&fbid='.$revision->getFBID())
->setTier('intern');
$links[] = array(
'blast',
<a href={$blast_uri}>Blast Revision</a>,
);
$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',
<a href={"/herald/transcript/?fbid=".$revision->getFBID()}
>Herald Transcripts</a>,
);
}

View file

@ -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');

View file

@ -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();
}

View file

@ -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;
}