Differential D20470 Diff 48878 src/applications/differential/engine/DifferentialDiffExtractionEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/engine/DifferentialDiffExtractionEngine.php
Show First 20 Lines • Show All 275 Lines • ▼ Show 20 Lines | public function updateRevisionWithCommit( | ||||
if (!$revision->isClosed() && !$revision->isAccepted()) { | if (!$revision->isClosed() && !$revision->isAccepted()) { | ||||
$wrong_type = DifferentialRevisionWrongStateTransaction::TRANSACTIONTYPE; | $wrong_type = DifferentialRevisionWrongStateTransaction::TRANSACTIONTYPE; | ||||
$xactions[] = id(new DifferentialTransaction()) | $xactions[] = id(new DifferentialTransaction()) | ||||
->setTransactionType($wrong_type) | ->setTransactionType($wrong_type) | ||||
->setNewValue($revision->getModernRevisionStatus()); | ->setNewValue($revision->getModernRevisionStatus()); | ||||
} | } | ||||
$concerning_builds = $this->loadConcerningBuilds($revision); | $concerning_builds = self::loadConcerningBuilds( | ||||
$this->getViewer(), | |||||
$revision, | |||||
$strict = false); | |||||
if ($concerning_builds) { | if ($concerning_builds) { | ||||
$build_list = array(); | $build_list = array(); | ||||
foreach ($concerning_builds as $build) { | foreach ($concerning_builds as $build) { | ||||
$build_list[] = array( | $build_list[] = array( | ||||
'phid' => $build->getPHID(), | 'phid' => $build->getPHID(), | ||||
'status' => $build->getBuildStatus(), | 'status' => $build->getBuildStatus(), | ||||
); | ); | ||||
} | } | ||||
Show All 30 Lines | public function updateRevisionWithCommit( | ||||
$author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
if ($author_phid !== null) { | if ($author_phid !== null) { | ||||
$editor->setActingAsPHID($author_phid); | $editor->setActingAsPHID($author_phid); | ||||
} | } | ||||
$editor->applyTransactions($revision, $xactions); | $editor->applyTransactions($revision, $xactions); | ||||
} | } | ||||
private function loadConcerningBuilds(DifferentialRevision $revision) { | public static function loadConcerningBuilds( | ||||
$viewer = $this->getViewer(); | PhabricatorUser $viewer, | ||||
DifferentialRevision $revision, | |||||
$strict) { | |||||
$diff = $revision->getActiveDiff(); | $diff = $revision->getActiveDiff(); | ||||
$buildables = id(new HarbormasterBuildableQuery()) | $buildables = id(new HarbormasterBuildableQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withBuildablePHIDs(array($diff->getPHID())) | ->withBuildablePHIDs(array($diff->getPHID())) | ||||
->needBuilds(true) | ->needBuilds(true) | ||||
->withManualBuildables(false) | ->withManualBuildables(false) | ||||
->execute(); | ->execute(); | ||||
if (!$buildables) { | if (!$buildables) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$land_key = HarbormasterBuildPlanBehavior::BEHAVIOR_LANDWARNING; | $land_key = HarbormasterBuildPlanBehavior::BEHAVIOR_LANDWARNING; | ||||
$behavior = HarbormasterBuildPlanBehavior::getBehavior($land_key); | $behavior = HarbormasterBuildPlanBehavior::getBehavior($land_key); | ||||
$key_never = HarbormasterBuildPlanBehavior::LANDWARNING_NEVER; | $key_never = HarbormasterBuildPlanBehavior::LANDWARNING_NEVER; | ||||
$key_building = HarbormasterBuildPlanBehavior::LANDWARNING_IF_BUILDING; | $key_building = HarbormasterBuildPlanBehavior::LANDWARNING_IF_BUILDING; | ||||
$key_complete = HarbormasterBuildPlanBehavior::LANDWARNING_IF_COMPLETE; | $key_complete = HarbormasterBuildPlanBehavior::LANDWARNING_IF_COMPLETE; | ||||
$concerning_builds = array(); | $concerning_builds = array(); | ||||
Show All 32 Lines | foreach ($buildables as $buildable) { | ||||
// We could refine this with a rule like "if the build finished | // We could refine this with a rule like "if the build finished | ||||
// within a couple of minutes before the push happened, assume it was | // within a couple of minutes before the push happened, assume it was | ||||
// in good faith", but we don't currently have an especially | // in good faith", but we don't currently have an especially | ||||
// convenient way to check when the build finished or when the commit | // convenient way to check when the build finished or when the commit | ||||
// was pushed or discovered, and this would create some issues in | // was pushed or discovered, and this would create some issues in | ||||
// cases where the repository is observed and the fetch pipeline | // cases where the repository is observed and the fetch pipeline | ||||
// stalls for a while. | // stalls for a while. | ||||
// If we're in strict mode (from a pre-commit content hook), we do | |||||
// not ignore these, since we're doing an instantaneous check against | |||||
// the current state. | |||||
if (!$strict) { | |||||
continue; | continue; | ||||
} | } | ||||
} | |||||
if ($build->isPassed()) { | if ($build->isPassed()) { | ||||
continue; | continue; | ||||
} | } | ||||
$concerning_builds[] = $build; | $concerning_builds[] = $build; | ||||
} | } | ||||
} | } | ||||
return $concerning_builds; | return $concerning_builds; | ||||
} | } | ||||
} | } |