Differential D21449 Diff 51085 src/applications/repository/storage/PhabricatorRepositoryCommitData.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepositoryCommitData.php
| <?php | <?php | ||||
| final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO { | final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO { | ||||
| protected $commitID; | protected $commitID; | ||||
| protected $authorName = ''; | protected $authorName = ''; | ||||
| protected $commitMessage = ''; | protected $commitMessage = ''; | ||||
| protected $commitDetails = array(); | protected $commitDetails = array(); | ||||
| private $commitRef; | |||||
| protected function getConfiguration() { | protected function getConfiguration() { | ||||
| return array( | return array( | ||||
| self::CONFIG_TIMESTAMPS => false, | self::CONFIG_TIMESTAMPS => false, | ||||
| self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
| 'commitDetails' => self::SERIALIZATION_JSON, | 'commitDetails' => self::SERIALIZATION_JSON, | ||||
| ), | ), | ||||
| self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | foreach ($holds as $key => $reason) { | ||||
| $holds[$key] = PhabricatorRepositoryPublisherHoldReason::newForHoldKey( | $holds[$key] = PhabricatorRepositoryPublisherHoldReason::newForHoldKey( | ||||
| $reason); | $reason); | ||||
| } | } | ||||
| return array_values($holds); | return array_values($holds); | ||||
| } | } | ||||
| public function getAuthorString() { | public function getAuthorString() { | ||||
| $author = phutil_string_cast($this->authorName); | $ref = $this->getCommitRef(); | ||||
| $author = $ref->getAuthor(); | |||||
| if (strlen($author)) { | |||||
| return $author; | |||||
| } | |||||
| $author = phutil_string_cast($this->authorName); | |||||
| if (strlen($author)) { | if (strlen($author)) { | ||||
| return $author; | return $author; | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function getAuthorDisplayName() { | public function getAuthorDisplayName() { | ||||
| return $this->getCommitDetailString('authorName'); | return $this->getCommitRef()->getAuthorName(); | ||||
| } | } | ||||
| public function getAuthorEmail() { | public function getAuthorEmail() { | ||||
| return $this->getCommitDetailString('authorEmail'); | return $this->getCommitRef()->getAuthorEmail(); | ||||
| } | } | ||||
| public function getAuthorEpoch() { | public function getAuthorEpoch() { | ||||
| $epoch = $this->getCommitDetail('authorEpoch'); | $epoch = $this->getCommitRef()->getAuthorEpoch(); | ||||
| if ($epoch) { | if ($epoch) { | ||||
| return (int)$epoch; | return (int)$epoch; | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function getCommitterString() { | public function getCommitterString() { | ||||
| $ref = $this->getCommitRef(); | |||||
| $committer = $ref->getCommitter(); | |||||
| if (strlen($committer)) { | |||||
| return $committer; | |||||
| } | |||||
| return $this->getCommitDetailString('committer'); | return $this->getCommitDetailString('committer'); | ||||
| } | } | ||||
| public function getCommitterDisplayName() { | public function getCommitterDisplayName() { | ||||
| return $this->getCommitDetailString('committerName'); | return $this->getCommitRef()->getCommitterName(); | ||||
| } | } | ||||
| public function getCommitterEmail() { | public function getCommitterEmail() { | ||||
| return $this->getCommitDetailString('committerEmail'); | return $this->getCommitRef()->getCommitterEmail(); | ||||
| } | } | ||||
| private function getCommitDetailString($key) { | private function getCommitDetailString($key) { | ||||
| $string = $this->getCommitDetail($key); | $string = $this->getCommitDetail($key); | ||||
| $string = phutil_string_cast($string); | $string = phutil_string_cast($string); | ||||
| if (strlen($string)) { | if (strlen($string)) { | ||||
| return $string; | return $string; | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function setCommitRef(DiffusionCommitRef $ref) { | |||||
| $this->setCommitDetail('ref', $ref->newDictionary()); | |||||
| $this->commitRef = null; | |||||
| return $this; | |||||
| } | |||||
| public function getCommitRef() { | |||||
| if ($this->commitRef === null) { | |||||
| $map = $this->getCommitDetail('ref', array()); | |||||
| if (!is_array($map)) { | |||||
| $map = array(); | |||||
| } | |||||
| $map = $map + array( | |||||
| 'authorName' => $this->getCommitDetailString('authorName'), | |||||
| 'authorEmail' => $this->getCommitDetailString('authorEmail'), | |||||
| 'authorEpoch' => $this->getCommitDetailString('authorEpoch'), | |||||
| 'committerName' => $this->getCommitDetailString('committerName'), | |||||
| 'committerEmail' => $this->getCommitDetailString('committerEmail'), | |||||
| 'message' => $this->getCommitMessage(), | |||||
| ); | |||||
| $ref = DiffusionCommitRef::newFromDictionary($map); | |||||
| $this->commitRef = $ref; | |||||
| } | |||||
| return $this->commitRef; | |||||
| } | |||||
| } | } | ||||