1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Make Differential load lint/unit data from Harbormaster

Summary: Fixes T8095. Still needs UI/UX work (see T8096) but this has all the core features now.

Test Plan: Saw Harbormaster lint/unit data as though it was Differential lint-unit data.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8095

Differential Revision: https://secure.phabricator.com/D13401
This commit is contained in:
epriestley 2015-06-23 07:09:23 -07:00
parent c4eef3dfcb
commit de30e15b7e
6 changed files with 76 additions and 37 deletions

View file

@ -10,7 +10,7 @@ return array(
'core.pkg.css' => 'eb51e6dc',
'core.pkg.js' => '711e63c0',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '02273347',
'differential.pkg.css' => '1ca3c116',
'differential.pkg.js' => 'ebef29b1',
'diffusion.pkg.css' => '591664fa',
'diffusion.pkg.js' => '0115b37c',
@ -61,7 +61,6 @@ return array(
'rsrc/css/application/differential/changeset-view.css' => 'e19cfd6e',
'rsrc/css/application/differential/core.css' => '7ac3cabc',
'rsrc/css/application/differential/phui-inline-comment.css' => 'aa16f165',
'rsrc/css/application/differential/results-table.css' => '181aa9d9',
'rsrc/css/application/differential/revision-comment.css' => '14b8565a',
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
@ -358,7 +357,6 @@ return array(
'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '037b59eb',
'rsrc/js/application/differential/behavior-keyboard-nav.js' => '2c426492',
'rsrc/js/application/differential/behavior-populate.js' => '8694b1df',
'rsrc/js/application/differential/behavior-show-field-details.js' => 'bba9eedf',
'rsrc/js/application/differential/behavior-toggle-files.js' => 'ca3f91eb',
'rsrc/js/application/differential/behavior-user-select.js' => 'a8d8459d',
'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => 'b42eddc7',
@ -513,7 +511,6 @@ return array(
'differential-changeset-view-css' => 'e19cfd6e',
'differential-core-view-css' => '7ac3cabc',
'differential-inline-comment-editor' => 'd4c87bf4',
'differential-results-table-css' => '181aa9d9',
'differential-revision-add-comment-css' => 'c47f8c40',
'differential-revision-comment-css' => '14b8565a',
'differential-revision-history-css' => '0e8eb855',
@ -567,7 +564,6 @@ return array(
'javelin-behavior-differential-feedback-preview' => 'b064af76',
'javelin-behavior-differential-keyboard-navigation' => '2c426492',
'javelin-behavior-differential-populate' => '8694b1df',
'javelin-behavior-differential-show-field-details' => 'bba9eedf',
'javelin-behavior-differential-toggle-files' => 'ca3f91eb',
'javelin-behavior-differential-user-select' => 'a8d8459d',
'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04',
@ -1705,11 +1701,6 @@ return array(
'javelin-workflow',
'phabricator-draggable-list',
),
'bba9eedf' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
),
'bd4c8dca' => array(
'javelin-install',
'javelin-util',
@ -2192,7 +2183,6 @@ return array(
'differential.pkg.css' => array(
'differential-core-view-css',
'differential-changeset-view-css',
'differential-results-table-css',
'differential-revision-history-css',
'differential-revision-list-css',
'differential-table-of-contents-css',

View file

@ -265,8 +265,25 @@ final class DifferentialRevisionViewController extends DifferentialController {
$revision_detail_box->setInfoView($revision_warnings);
}
$detail_diffs = array_select_keys(
$diffs,
array($diff_vs, $target->getID()));
$detail_diffs = mpull($detail_diffs, null, 'getPHID');
$buildables = id(new HarbormasterBuildableQuery())
->setViewer($user)
->withBuildablePHIDs(array_keys($detail_diffs))
->withManualBuildables(false)
->needBuilds(true)
->needTargets(true)
->execute();
$buildables = mpull($buildables, null, 'getBuildablePHID');
foreach ($detail_diffs as $diff_phid => $detail_diff) {
$detail_diff->attachBuildable(idx($buildables, $diff_phid));
}
$diff_detail_box = $this->buildDiffDetailView(
array_select_keys($diffs, array($diff_vs, $target->getID())),
$detail_diffs,
$revision,
$field_list);

View file

@ -54,7 +54,19 @@ final class DifferentialLintField
$lint = array();
// TODO: Look for Harbormaster messages here.
$buildable = $diff->getBuildable();
if ($buildable) {
$target_phids = array();
foreach ($buildable->getBuilds() as $build) {
foreach ($build->getBuildTargets() as $target) {
$target_phids[] = $target->getPHID();
}
}
$lint = id(new HarbormasterBuildLintMessage())->loadAllWhere(
'buildTargetPHID IN (%Ls) LIMIT 25',
$target_phids);
}
if (!$lint) {
// No Harbormaster messages, so look for legacy messages and make them

View file

@ -52,7 +52,19 @@ final class DifferentialUnitField
$unit = array();
// TODO: Look for Harbormaster results here.
$buildable = $diff->getBuildable();
if ($buildable) {
$target_phids = array();
foreach ($buildable->getBuilds() as $build) {
foreach ($build->getBuildTargets() as $target) {
$target_phids[] = $target->getPHID();
}
}
$unit = id(new HarbormasterBuildUnitMessage())->loadAllWhere(
'buildTargetPHID IN (%Ls) LIMIT 25',
$target_phids);
}
if (!$unit) {
$legacy_unit = $diff->getProperty('arc:unit');

View file

@ -39,6 +39,7 @@ final class DifferentialDiff
private $changesets = self::ATTACHABLE;
private $revision = self::ATTACHABLE;
private $properties = array();
private $buildable = self::ATTACHABLE;
protected function getConfiguration() {
return array(
@ -323,6 +324,15 @@ final class DifferentialDiff
return $this->assertAttachedKey($this->properties, $key);
}
public function attachBuildable(HarbormasterBuildable $buildable = null) {
$this->buildable = $buildable;
return $this;
}
public function getBuildable() {
return $this->assertAttached($this->buildable);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -13,6 +13,7 @@ final class HarbormasterBuildableQuery
private $needContainerHandles;
private $needBuildableHandles;
private $needBuilds;
private $needTargets;
public function withIDs(array $ids) {
$this->ids = $ids;
@ -59,19 +60,17 @@ final class HarbormasterBuildableQuery
return $this;
}
public function needTargets($need) {
$this->needTargets = $need;
return $this;
}
public function newResultObject() {
return new HarbormasterBuildable();
}
protected function loadPage() {
$table = new HarbormasterBuildable();
$conn_r = $table->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T %Q %Q %Q',
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
return $table->loadAllFromArray($data);
return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $page) {
@ -157,11 +156,12 @@ final class HarbormasterBuildableQuery
}
}
if ($this->needBuilds) {
if ($this->needBuilds || $this->needTargets) {
$builds = id(new HarbormasterBuildQuery())
->setViewer($this->getViewer())
->setParentQuery($this)
->withBuildablePHIDs(mpull($page, 'getPHID'))
->needBuildTargets($this->needTargets)
->execute();
$builds = mgroup($builds, 'getBuildablePHID');
foreach ($page as $key => $buildable) {
@ -172,47 +172,45 @@ final class HarbormasterBuildableQuery
return $page;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->buildablePHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'buildablePHID IN (%Ls)',
$this->buildablePHIDs);
}
if ($this->containerPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'containerPHID in (%Ls)',
$this->containerPHIDs);
}
if ($this->manualBuildables !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'isManualBuildable = %d',
(int)$this->manualBuildables);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
return $where;
}
public function getQueryApplicationClass() {