Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
3.6 kB · 150 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151<?php
final class DiffusionCommitRef extends Phobject {
private $message; private $authorEpoch; private $authorName; private $authorEmail; private $committerName; private $committerEmail; private $hashes = array();
public function newDictionary() { $hashes = $this->getHashes(); $hashes = mpull($hashes, 'newDictionary'); $hashes = array_values($hashes);
return array( 'authorEpoch' => $this->authorEpoch, 'authorName' => $this->authorName, 'authorEmail' => $this->authorEmail, 'committerName' => $this->committerName, 'committerEmail' => $this->committerEmail, 'message' => $this->message, 'hashes' => $hashes, ); }
public static function newFromDictionary(array $map) { $hashes = idx($map, 'hashes', array()); foreach ($hashes as $key => $hash_map) { $hashes[$key] = DiffusionCommitHash::newFromDictionary($hash_map); } $hashes = array_values($hashes);
$author_epoch = idx($map, 'authorEpoch'); $author_name = idx($map, 'authorName'); $author_email = idx($map, 'authorEmail'); $committer_name = idx($map, 'committerName'); $committer_email = idx($map, 'committerEmail'); $message = idx($map, 'message');
return id(new self()) ->setAuthorEpoch($author_epoch) ->setAuthorName($author_name) ->setAuthorEmail($author_email) ->setCommitterName($committer_name) ->setCommitterEmail($committer_email) ->setMessage($message) ->setHashes($hashes); }
/** * @param array<DiffusionCommitHash> $hashes */ public function setHashes(array $hashes) { assert_instances_of($hashes, DiffusionCommitHash::class); $this->hashes = $hashes; return $this; }
public function getHashes() { return $this->hashes; }
public function setAuthorEpoch($author_epoch) { $this->authorEpoch = $author_epoch; return $this; }
public function getAuthorEpoch() { return $this->authorEpoch; }
public function setCommitterEmail($committer_email) { $this->committerEmail = $committer_email; return $this; }
public function getCommitterEmail() { return $this->committerEmail; }
public function setCommitterName($committer_name) { $this->committerName = $committer_name; return $this; }
public function getCommitterName() { return $this->committerName; }
public function setAuthorEmail($author_email) { $this->authorEmail = $author_email; return $this; }
public function getAuthorEmail() { return $this->authorEmail; }
public function setAuthorName($author_name) { $this->authorName = $author_name; return $this; }
public function getAuthorName() { return $this->authorName; }
public function setMessage($message) { $this->message = $message; return $this; }
public function getMessage() { return $this->message; }
public function getAuthor() { return $this->formatUser($this->authorName, $this->authorEmail); }
public function getCommitter() { return $this->formatUser($this->committerName, $this->committerEmail); }
public function getSummary() { return PhabricatorRepositoryCommitData::summarizeCommitMessage( $this->getMessage()); }
private function formatUser($name, $email) { $name = coalesce($name, ''); $email = coalesce($email, ''); if (strlen($name) && strlen($email)) { return "{$name} <{$email}>"; } else if (strlen($email)) { return $email; } else if (strlen($name)) { return $name; } else { return null; } }
}