3 final class DiffusionCommitRef
extends Phobject
{
9 private $committerName;
10 private $committerEmail;
11 private $hashes = array();
13 public function newDictionary() {
14 $hashes = $this->getHashes();
15 $hashes = mpull($hashes, 'newDictionary');
16 $hashes = array_values($hashes);
19 'authorEpoch' => $this->authorEpoch
,
20 'authorName' => $this->authorName
,
21 'authorEmail' => $this->authorEmail
,
22 'committerName' => $this->committerName
,
23 'committerEmail' => $this->committerEmail
,
24 'message' => $this->message
,
29 public static function newFromDictionary(array $map) {
30 $hashes = idx($map, 'hashes', array());
31 foreach ($hashes as $key => $hash_map) {
32 $hashes[$key] = DiffusionCommitHash
::newFromDictionary($hash_map);
34 $hashes = array_values($hashes);
36 $author_epoch = idx($map, 'authorEpoch');
37 $author_name = idx($map, 'authorName');
38 $author_email = idx($map, 'authorEmail');
39 $committer_name = idx($map, 'committerName');
40 $committer_email = idx($map, 'committerEmail');
41 $message = idx($map, 'message');
44 ->setAuthorEpoch($author_epoch)
45 ->setAuthorName($author_name)
46 ->setAuthorEmail($author_email)
47 ->setCommitterName($committer_name)
48 ->setCommitterEmail($committer_email)
49 ->setMessage($message)
53 public function setHashes(array $hashes) {
54 assert_instances_of($hashes, 'DiffusionCommitHash');
55 $this->hashes
= $hashes;
59 public function getHashes() {
63 public function setAuthorEpoch($author_epoch) {
64 $this->authorEpoch
= $author_epoch;
68 public function getAuthorEpoch() {
69 return $this->authorEpoch
;
72 public function setCommitterEmail($committer_email) {
73 $this->committerEmail
= $committer_email;
77 public function getCommitterEmail() {
78 return $this->committerEmail
;
82 public function setCommitterName($committer_name) {
83 $this->committerName
= $committer_name;
87 public function getCommitterName() {
88 return $this->committerName
;
92 public function setAuthorEmail($author_email) {
93 $this->authorEmail
= $author_email;
97 public function getAuthorEmail() {
98 return $this->authorEmail
;
102 public function setAuthorName($author_name) {
103 $this->authorName
= $author_name;
107 public function getAuthorName() {
108 return $this->authorName
;
111 public function setMessage($message) {
112 $this->message
= $message;
116 public function getMessage() {
117 return $this->message
;
120 public function getAuthor() {
121 return $this->formatUser($this->authorName
, $this->authorEmail
);
124 public function getCommitter() {
125 return $this->formatUser($this->committerName
, $this->committerEmail
);
128 public function getSummary() {
129 return PhabricatorRepositoryCommitData
::summarizeCommitMessage(
130 $this->getMessage());
133 private function formatUser($name, $email) {
134 if ($name === null) {
137 if ($email === null) {
141 if (strlen($name) && strlen($email)) {
142 return "{$name} <{$email}>";
143 } else if (strlen($email)) {
145 } else if (strlen($name)) {