Path: blob/master/src/applications/differential/harbormaster/DifferentialBuildableEngine.php
12256 views
<?php12final class DifferentialBuildableEngine3extends HarbormasterBuildableEngine {45protected function getPublishableObject() {6$object = $this->getObject();78if ($object instanceof DifferentialDiff) {9if ($object->getRevisionID()) {10return $object->getRevision();11} else {12return null;13}14}1516return $object;17}1819public function publishBuildable(20HarbormasterBuildable $old,21HarbormasterBuildable $new) {2223// If we're publishing to a diff that is not actually attached to a24// revision, we have nothing to publish to, so just bail out.25$revision = $this->getPublishableObject();26if (!$revision) {27return;28}2930// Don't publish manual buildables.31if ($new->getIsManualBuildable()) {32return;33}3435// Don't publish anything if the buildable is still building. Differential36// treats more buildables as "building" than Harbormaster does, but the37// Differential definition is a superset of the Harbormaster definition.38if ($new->isBuilding()) {39return;40}4142$viewer = $this->getViewer();4344$old_status = $revision->getBuildableStatus($new->getPHID());45$new_status = $revision->newBuildableStatus($viewer, $new->getPHID());46if ($old_status === $new_status) {47return;48}4950$buildable_type = DifferentialRevisionBuildableTransaction::TRANSACTIONTYPE;5152$xaction = $this->newTransaction()53->setMetadataValue('harbormaster:buildablePHID', $new->getPHID())54->setTransactionType($buildable_type)55->setNewValue($new_status);5657$this->applyTransactions(array($xaction));58}5960public function getAuthorIdentity() {61$object = $this->getObject();6263if ($object instanceof DifferentialRevision) {64$object = $object->loadActiveDiff();65}6667$authorship = $object->getDiffAuthorshipDict();68if (!isset($authorship['authorName'])) {69return null;70}7172$name = $authorship['authorName'];73$address = idx($authorship, 'authorEmail');7475$full = id(new PhutilEmailAddress())76->setDisplayName($name)77->setAddress($address);7879return id(new PhabricatorRepositoryIdentity())80->setIdentityName((string)$full)81->makeEphemeral();82}8384}858687