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

Read synthetic inline comments from Harbormaster

Summary: Ref T8096. These are still reading out of the old diff property, but should read from Harbormaster instead.

Test Plan: {F698346}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8096

Differential Revision: https://secure.phabricator.com/D13847
This commit is contained in:
epriestley 2015-08-10 14:16:14 -07:00
parent c2c8b00c5c
commit 2b13da88ce

View file

@ -203,6 +203,29 @@ final class DifferentialChangesetViewController extends DifferentialController {
$inlines = array(); $inlines = array();
} }
if ($left_new || $right_new) {
$diff_map = array();
if ($left) {
$diff_map[] = $left->getDiff();
}
if ($right) {
$diff_map[] = $right->getDiff();
}
$diff_map = mpull($diff_map, null, 'getPHID');
$buildables = id(new HarbormasterBuildableQuery())
->setViewer($viewer)
->withBuildablePHIDs(array_keys($diff_map))
->withManualBuildables(false)
->needBuilds(true)
->needTargets(true)
->execute();
$buildables = mpull($buildables, null, 'getBuildablePHID');
foreach ($diff_map as $diff_phid => $changeset_diff) {
$changeset_diff->attachBuildable(idx($buildables, $diff_phid));
}
}
if ($left_new) { if ($left_new) {
$inlines = array_merge( $inlines = array_merge(
$inlines, $inlines,
@ -356,30 +379,47 @@ final class DifferentialChangesetViewController extends DifferentialController {
} }
private function buildLintInlineComments($changeset) { private function buildLintInlineComments($changeset) {
$lint = id(new DifferentialDiffProperty())->loadOneWhere( $diff = $changeset->getDiff();
'diffID = %d AND name = %s',
$changeset->getDiffID(), $buildable = $diff->getBuildable();
'arc:lint'); if (!$buildable) {
if (!$lint) {
return array(); return array();
} }
$lint = $lint->getData();
$target_phids = array();
foreach ($buildable->getBuilds() as $build) {
foreach ($build->getBuildTargets() as $target) {
$target_phids[] = $target->getPHID();
}
}
if (!$target_phids) {
return array();
}
$messages = id(new HarbormasterBuildLintMessage())->loadAllWhere(
'buildTargetPHID IN (%Ls) AND path = %s',
$target_phids,
$changeset->getFilename());
if (!$messages) {
return array();
}
$template = id(new DifferentialInlineComment())
->setChangesetID($changeset->getID())
->setIsNewFile(1)
->setLineLength(0);
$inlines = array(); $inlines = array();
foreach ($lint as $msg) { foreach ($messages as $message) {
if ($msg['path'] != $changeset->getFilename()) { $description = $message->getProperty('description');
continue; $description = '%%%'.$description.'%%%';
}
$inline = new DifferentialInlineComment();
$inline->setChangesetID($changeset->getID());
$inline->setIsNewFile(1);
$inline->setSyntheticAuthor(pht('Lint: %s', $msg['name']));
$inline->setLineNumber($msg['line']);
$inline->setLineLength(0);
$inline->setContent('%%%'.$msg['description'].'%%%'); $inlines[] = id(clone $template)
->setSyntheticAuthor(pht('Lint: %s', $message->getName()))
$inlines[] = $inline; ->setLineNumber($message->getLine())
->setContent($description);
} }
return $inlines; return $inlines;