Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
| Show All 25 Lines | final class DiffusionCommitHookEngine extends Phobject { | ||||
| private $subversionRepository; | private $subversionRepository; | ||||
| private $remoteAddress; | private $remoteAddress; | ||||
| private $remoteProtocol; | private $remoteProtocol; | ||||
| private $requestIdentifier; | private $requestIdentifier; | ||||
| private $transactionKey; | private $transactionKey; | ||||
| private $mercurialHook; | private $mercurialHook; | ||||
| private $mercurialCommits = array(); | private $mercurialCommits = array(); | ||||
| private $gitCommits = array(); | private $gitCommits = array(); | ||||
| private $startTime; | |||||
| private $heraldViewerProjects; | private $heraldViewerProjects; | ||||
| private $rejectCode = PhabricatorRepositoryPushLog::REJECT_BROKEN; | private $rejectCode = PhabricatorRepositoryPushLog::REJECT_BROKEN; | ||||
| private $rejectDetails; | private $rejectDetails; | ||||
| private $emailPHIDs = array(); | private $emailPHIDs = array(); | ||||
| private $changesets = array(); | private $changesets = array(); | ||||
| private $changesetsSize = 0; | private $changesetsSize = 0; | ||||
| Show All 23 Lines | public function setRequestIdentifier($request_identifier) { | ||||
| $this->requestIdentifier = $request_identifier; | $this->requestIdentifier = $request_identifier; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getRequestIdentifier() { | public function getRequestIdentifier() { | ||||
| return $this->requestIdentifier; | return $this->requestIdentifier; | ||||
| } | } | ||||
| public function setStartTime($start_time) { | |||||
| $this->startTime = $start_time; | |||||
| return $this; | |||||
| } | |||||
| public function getStartTime() { | |||||
| return $this->startTime; | |||||
| } | |||||
| public function setSubversionTransactionInfo($transaction, $repository) { | public function setSubversionTransactionInfo($transaction, $repository) { | ||||
| $this->subversionTransaction = $transaction; | $this->subversionTransaction = $transaction; | ||||
| $this->subversionRepository = $repository; | $this->subversionRepository = $repository; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setStdin($stdin) { | public function setStdin($stdin) { | ||||
| $this->stdin = $stdin; | $this->stdin = $stdin; | ||||
| ▲ Show 20 Lines • Show All 1,016 Lines • ▼ Show 20 Lines | return PhabricatorRepositoryPushLog::initializeNewLog($this->getViewer()) | ||||
| ->setRepositoryPHID($this->getRepository()->getPHID()) | ->setRepositoryPHID($this->getRepository()->getPHID()) | ||||
| ->attachRepository($this->getRepository()) | ->attachRepository($this->getRepository()) | ||||
| ->setEpoch(PhabricatorTime::getNow()); | ->setEpoch(PhabricatorTime::getNow()); | ||||
| } | } | ||||
| private function newPushEvent() { | private function newPushEvent() { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $hook_start = $this->getStartTime(); | |||||
| $hook_end = microtime(true); | |||||
| $event = PhabricatorRepositoryPushEvent::initializeNewEvent($viewer) | $event = PhabricatorRepositoryPushEvent::initializeNewEvent($viewer) | ||||
| ->setRepositoryPHID($this->getRepository()->getPHID()) | ->setRepositoryPHID($this->getRepository()->getPHID()) | ||||
| ->setRemoteAddress($this->getRemoteAddress()) | ->setRemoteAddress($this->getRemoteAddress()) | ||||
| ->setRemoteProtocol($this->getRemoteProtocol()) | ->setRemoteProtocol($this->getRemoteProtocol()) | ||||
| ->setEpoch(PhabricatorTime::getNow()); | ->setEpoch(PhabricatorTime::getNow()) | ||||
| ->setHookWait((int)(1000000 * ($hook_end - $hook_start))); | |||||
amckinley: I know this is a really trivial amount of code to factor out into a function, but I'm still… | |||||
| $identifier = $this->getRequestIdentifier(); | $identifier = $this->getRequestIdentifier(); | ||||
| if (strlen($identifier)) { | if (strlen($identifier)) { | ||||
| $event->setRequestIdentifier($identifier); | $event->setRequestIdentifier($identifier); | ||||
| } | } | ||||
| return $event; | return $event; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines | |||||
I know this is a really trivial amount of code to factor out into a function, but I'm still surprised this isn't a libphutil function since we have this construction alllll over the place.