Changeset View
Changeset View
Standalone View
Standalone View
src/ref/ArcanistCommitRef.php
| <?php | <?php | ||||
| final class ArcanistCommitRef | final class ArcanistCommitRef | ||||
| extends ArcanistRef { | extends ArcanistRef { | ||||
| private $commitHash; | private $commitHash; | ||||
| private $treeHash; | private $treeHash; | ||||
| private $commitEpoch; | private $commitEpoch; | ||||
| private $authorEpoch; | private $authorEpoch; | ||||
| private $upstream; | private $upstream; | ||||
| public function getRefIdentifier() { | const HARDPOINT_MESSAGE = 'message'; | ||||
| return pht('Commit %s', $this->getCommitHash()); | const HARDPOINT_UPSTREAM = 'upstream'; | ||||
| public function getRefDisplayName() { | |||||
| return pht('Commit "%s"', $this->getCommitHash()); | |||||
| } | } | ||||
| public function defineHardpoints() { | protected function newHardpoints() { | ||||
| return array( | return array( | ||||
| 'message' => array( | $this->newHardpoint(self::HARDPOINT_MESSAGE), | ||||
| 'type' => 'string', | $this->newHardpoint(self::HARDPOINT_UPSTREAM), | ||||
| ), | |||||
| 'upstream' => array( | |||||
| 'type' => 'wild', | |||||
| ), | |||||
| ); | ); | ||||
| } | } | ||||
| public function setCommitHash($commit_hash) { | public function setCommitHash($commit_hash) { | ||||
| $this->commitHash = $commit_hash; | $this->commitHash = $commit_hash; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| Show All 33 Lines | public function getSummary() { | ||||
| $message = trim($message); | $message = trim($message); | ||||
| $lines = phutil_split_lines($message, false); | $lines = phutil_split_lines($message, false); | ||||
| return head($lines); | return head($lines); | ||||
| } | } | ||||
| public function attachMessage($message) { | public function attachMessage($message) { | ||||
| return $this->attachHardpoint('message', $message); | return $this->attachHardpoint(self::HARDPOINT_MESSAGE, $message); | ||||
| } | } | ||||
| public function getMessage() { | public function getMessage() { | ||||
| return $this->getHardpoint('message'); | return $this->getHardpoint(self::HARDPOINT_MESSAGE); | ||||
| } | } | ||||
| public function getURI() { | public function getURI() { | ||||
| return $this->getUpstreamProperty('uri'); | return $this->getUpstreamProperty('uri'); | ||||
| } | } | ||||
| private function getUpstreamProperty($key, $default = null) { | private function getUpstreamProperty($key, $default = null) { | ||||
| $upstream = $this->getHardpoint('upstream'); | $upstream = $this->getHardpoint(self::HARDPOINT_UPSTREAM); | ||||
| if (!$upstream) { | if (!$upstream) { | ||||
| return $default; | return $default; | ||||
| } | } | ||||
| return idx($upstream, $key, $default); | return idx($upstream, $key, $default); | ||||
| } | } | ||||
| } | } | ||||