@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Read Differential changeset coverage information from Harbormaster

Summary: Ref T8096. This information has moved into Harbormaster.

Test Plan:
Pushed some test results in; see right margin:

{F698394}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8096

Differential Revision: https://secure.phabricator.com/D13850

+69 -70
+48 -56
src/applications/differential/controller/DifferentialChangesetViewController.php
··· 127 127 $changeset = $choice; 128 128 } 129 129 130 - $coverage = null; 131 - if ($right && $right->getDiffID()) { 132 - $unit = id(new DifferentialDiffProperty())->loadOneWhere( 133 - 'diffID = %d AND name = %s', 134 - $right->getDiffID(), 135 - 'arc:unit'); 130 + if ($left_new || $right_new) { 131 + $diff_map = array(); 132 + if ($left) { 133 + $diff_map[] = $left->getDiff(); 134 + } 135 + if ($right) { 136 + $diff_map[] = $right->getDiff(); 137 + } 138 + $diff_map = mpull($diff_map, null, 'getPHID'); 136 139 137 - if ($unit) { 138 - $coverage = array(); 139 - foreach ($unit->getData() as $result) { 140 - $result_coverage = idx($result, 'coverage'); 141 - if (!$result_coverage) { 142 - continue; 143 - } 144 - $file_coverage = idx($result_coverage, $right->getFileName()); 145 - if (!$file_coverage) { 146 - continue; 147 - } 148 - $coverage[] = $file_coverage; 149 - } 140 + $buildables = id(new HarbormasterBuildableQuery()) 141 + ->setViewer($viewer) 142 + ->withBuildablePHIDs(array_keys($diff_map)) 143 + ->withManualBuildables(false) 144 + ->needBuilds(true) 145 + ->needTargets(true) 146 + ->execute(); 147 + $buildables = mpull($buildables, null, 'getBuildablePHID'); 148 + foreach ($diff_map as $diff_phid => $changeset_diff) { 149 + $changeset_diff->attachBuildable(idx($buildables, $diff_phid)); 150 + } 151 + } 150 152 151 - $coverage = ArcanistUnitTestResult::mergeCoverage($coverage); 152 - } 153 + $coverage = null; 154 + if ($right_new) { 155 + $coverage = $this->loadCoverage($right); 153 156 } 154 157 155 158 $spec = $request->getStr('range'); ··· 201 204 $revision); 202 205 } else { 203 206 $inlines = array(); 204 - } 205 - 206 - if ($left_new || $right_new) { 207 - $diff_map = array(); 208 - if ($left) { 209 - $diff_map[] = $left->getDiff(); 210 - } 211 - if ($right) { 212 - $diff_map[] = $right->getDiff(); 213 - } 214 - $diff_map = mpull($diff_map, null, 'getPHID'); 215 - 216 - $buildables = id(new HarbormasterBuildableQuery()) 217 - ->setViewer($viewer) 218 - ->withBuildablePHIDs(array_keys($diff_map)) 219 - ->withManualBuildables(false) 220 - ->needBuilds(true) 221 - ->needTargets(true) 222 - ->execute(); 223 - $buildables = mpull($buildables, null, 'getBuildablePHID'); 224 - foreach ($diff_map as $diff_phid => $changeset_diff) { 225 - $changeset_diff->attachBuildable(idx($buildables, $diff_phid)); 226 - } 227 207 } 228 208 229 209 if ($left_new) { ··· 381 361 private function buildLintInlineComments($changeset) { 382 362 $diff = $changeset->getDiff(); 383 363 384 - $buildable = $diff->getBuildable(); 385 - if (!$buildable) { 386 - return array(); 387 - } 388 - 389 - $target_phids = array(); 390 - foreach ($buildable->getBuilds() as $build) { 391 - foreach ($build->getBuildTargets() as $target) { 392 - $target_phids[] = $target->getPHID(); 393 - } 394 - } 395 - 364 + $target_phids = $diff->getBuildTargetPHIDs(); 396 365 if (!$target_phids) { 397 366 return array(); 398 367 } ··· 423 392 } 424 393 425 394 return $inlines; 395 + } 396 + 397 + private function loadCoverage(DifferentialChangeset $changeset) { 398 + $target_phids = $changeset->getDiff()->getBuildTargetPHIDs(); 399 + if (!$target_phids) { 400 + return array(); 401 + } 402 + 403 + $unit = id(new HarbormasterBuildUnitMessage())->loadAllWhere( 404 + 'buildTargetPHID IN (%Ls)', 405 + $target_phids); 406 + 407 + $coverage = array(); 408 + foreach ($unit as $message) { 409 + $test_coverage = $message->getProperty('coverage', array()); 410 + $coverage_data = idx($test_coverage, $changeset->getFileName()); 411 + if (!strlen($coverage_data)) { 412 + continue; 413 + } 414 + $coverage[] = $coverage_data; 415 + } 416 + 417 + return ArcanistUnitTestResult::mergeCoverage($coverage); 426 418 } 427 419 428 420 }
+5 -14
src/applications/differential/customfield/DifferentialHarbormasterField.php
··· 29 29 $diff->attachProperty($key, idx($properties, $key)); 30 30 } 31 31 32 - $messages = array(); 33 - 34 - $buildable = $diff->getBuildable(); 35 - if ($buildable) { 36 - $target_phids = array(); 37 - foreach ($buildable->getBuilds() as $build) { 38 - foreach ($build->getBuildTargets() as $target) { 39 - $target_phids[] = $target->getPHID(); 40 - } 41 - } 42 - 43 - if ($target_phids) { 44 - $messages = $this->loadHarbormasterTargetMessages($target_phids); 45 - } 32 + $target_phids = $diff->getBuildTargetPHIDs(); 33 + if ($target_phids) { 34 + $messages = $this->loadHarbormasterTargetMessages($target_phids); 35 + } else { 36 + $messages = array(); 46 37 } 47 38 48 39 if (!$messages) {
+16
src/applications/differential/storage/DifferentialDiff.php
··· 331 331 return $this->assertAttached($this->buildable); 332 332 } 333 333 334 + public function getBuildTargetPHIDs() { 335 + $buildable = $this->getBuildable(); 336 + 337 + if (!$buildable) { 338 + return array(); 339 + } 340 + 341 + $target_phids = array(); 342 + foreach ($buildable->getBuilds() as $build) { 343 + foreach ($build->getBuildTargets() as $target) { 344 + $target_phids[] = $target->getPHID(); 345 + } 346 + } 347 + 348 + return $target_phids; 349 + } 334 350 335 351 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 336 352