3 final class DifferentialLocalCommitsView
extends AphrontView
{
6 private $commitsForLinks = array();
8 public function setLocalCommits($local_commits) {
9 $this->localCommits
= $local_commits;
13 public function setCommitsForLinks(array $commits) {
14 assert_instances_of($commits, 'PhabricatorRepositoryCommit');
15 $this->commitsForLinks
= $commits;
19 public function render() {
20 $viewer = $this->getViewer();
22 $local = $this->localCommits
;
30 foreach ($local as $commit) {
31 if (idx($commit, 'tree')) {
34 if (idx($commit, 'local')) {
40 foreach ($local as $commit) {
42 if (idx($commit, 'commit')) {
43 $commit_link = $this->buildCommitLink($commit['commit']);
44 } else if (isset($commit['rev'])) {
45 $commit_link = $this->buildCommitLink($commit['rev']);
49 $row[] = $commit_link;
52 $row[] = $this->buildCommitLink($commit['tree']);
56 $row[] = $this->buildCommitLink($commit['local']);
59 $parents = idx($commit, 'parents', array());
60 foreach ($parents as $k => $parent) {
61 if (is_array($parent)) {
62 $parent = idx($parent, 'rev');
64 $parents[$k] = $this->buildCommitLink($parent);
66 $parents = phutil_implode_html(phutil_tag('br'), $parents);
71 idx($commit, 'author'));
74 $message = idx($commit, 'message');
76 $summary = idx($commit, 'summary');
77 $summary = id(new PhutilUTF8StringTruncator())
78 ->setMaximumGlyphs(80)
79 ->truncateString($summary);
81 $view = new AphrontMoreView();
82 $view->setSome($summary);
84 if ($message && (trim($summary) != trim($message))) {
85 $view->setMore(phutil_escape_html_newlines($message));
88 $row[] = $view->render();
92 idx($commit, 'time'));
94 $date = phabricator_datetime($date, $viewer);
101 $column_classes = array('');
103 $column_classes[] = '';
106 $column_classes[] = '';
108 $column_classes[] = '';
109 $column_classes[] = '';
110 $column_classes[] = 'wide';
111 $column_classes[] = 'date';
112 $table = id(new AphrontTableView($rows))
113 ->setColumnClasses($column_classes);
115 $headers[] = pht('Commit');
117 $headers[] = pht('Tree');
120 $headers[] = pht('Local');
122 $headers[] = pht('Parents');
123 $headers[] = pht('Author');
124 $headers[] = pht('Summary');
125 $headers[] = pht('Date');
126 $table->setHeaders($headers);
131 private static function formatCommit($commit) {
132 return substr($commit, 0, 12);
135 private function buildCommitLink($hash) {
136 $commit_for_link = idx($this->commitsForLinks
, $hash);
137 $commit_hash = self
::formatCommit($hash);
138 if ($commit_for_link) {
142 'href' => $commit_for_link->getURI(),
146 $link = $commit_hash;