Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/herald/HeraldCommitAdapter.php
| Show All 29 Lines | final class HeraldCommitAdapter | ||||
| } | } | ||||
| public function getAdapterTestDescription() { | public function getAdapterTestDescription() { | ||||
| return pht( | return pht( | ||||
| 'Test rules which run after a commit is discovered and imported.'); | 'Test rules which run after a commit is discovered and imported.'); | ||||
| } | } | ||||
| public function newTestAdapter(PhabricatorUser $viewer, $object) { | public function newTestAdapter(PhabricatorUser $viewer, $object) { | ||||
| $object = id(new DiffusionCommitQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($object->getPHID())) | |||||
| ->needCommitData(true) | |||||
| ->executeOne(); | |||||
| if (!$object) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Failed to reload commit ("%s") to fetch commit data.', | |||||
| $object->getPHID())); | |||||
| } | |||||
| return id(clone $this) | return id(clone $this) | ||||
| ->setObject($object); | ->setObject($object); | ||||
| } | } | ||||
| protected function initializeNewAdapter() { | protected function initializeNewAdapter() { | ||||
| $this->commit = $this->newObject(); | $this->commit = $this->newObject(); | ||||
| } | } | ||||
| public function setObject($object) { | public function setObject($object) { | ||||
| $this->commit = $object; | $viewer = $this->getViewer(); | ||||
| $commit_phid = $object->getPHID(); | |||||
| $commit = id(new DiffusionCommitQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($commit_phid)) | |||||
| ->needCommitData(true) | |||||
| ->needIdentities(true) | |||||
| ->executeOne(); | |||||
| if (!$commit) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Failed to reload commit ("%s") to fetch commit data.', | |||||
| $commit_phid)); | |||||
| } | |||||
| $this->commit = $commit; | |||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getObject() { | public function getObject() { | ||||
| return $this->commit; | return $this->commit; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | return DiffusionQuery::callConduitWithDiffusionRequest( | ||||
| $method, | $method, | ||||
| $params); | $params); | ||||
| } | } | ||||
| private function getRepository() { | private function getRepository() { | ||||
| return $this->getObject()->getRepository(); | return $this->getObject()->getRepository(); | ||||
| } | } | ||||
| public function getAuthorPHID() { | |||||
| return $this->getObject()->getEffectiveAuthorPHID(); | |||||
| } | |||||
| public function getCommitterPHID() { | |||||
| $commit = $this->getObject(); | |||||
| if ($commit->hasCommitterIdentity()) { | |||||
| $identity = $commit->getCommitterIdentity(); | |||||
| return $identity->getCurrentEffectiveUserPHID(); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /* -( HarbormasterBuildableAdapterInterface )------------------------------ */ | /* -( HarbormasterBuildableAdapterInterface )------------------------------ */ | ||||
| public function getHarbormasterBuildablePHID() { | public function getHarbormasterBuildablePHID() { | ||||
| return $this->getObject()->getPHID(); | return $this->getObject()->getPHID(); | ||||
| } | } | ||||
| public function getHarbormasterContainerPHID() { | public function getHarbormasterContainerPHID() { | ||||
| Show All 13 Lines | |||||