Differential D21574 Diff 51360 src/applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public function renderHovercard( | ||||
$phids = array(); | $phids = array(); | ||||
$phids[] = $author_phid; | $phids[] = $author_phid; | ||||
$phids[] = $committer_phid; | $phids[] = $committer_phid; | ||||
$phids[] = $repository_phid; | $phids[] = $repository_phid; | ||||
$handles = $viewer->loadHandles($phids); | $handles = $viewer->loadHandles($phids); | ||||
$hovercard->setTitle($handle->getName()); | $hovercard->setTitle($handle->getName()); | ||||
$hovercard->setDetail($commit->getSummary()); | |||||
// See T13620. Use a longer slice of the message than the "summary" here, | |||||
// since we have at least a few lines of room in the UI. | |||||
$commit_message = $commit->getCommitMessageForDisplay(); | |||||
$message_limit = 512; | |||||
$short_message = id(new PhutilUTF8StringTruncator()) | |||||
->setMaximumBytes($message_limit * 4) | |||||
->setMaximumGlyphs($message_limit) | |||||
->truncateString($commit_message); | |||||
$short_message = phutil_escape_html_newlines($short_message); | |||||
$hovercard->setDetail($short_message); | |||||
$repository = $handles[$repository_phid]->renderLink(); | $repository = $handles[$repository_phid]->renderLink(); | ||||
$hovercard->addField(pht('Repository'), $repository); | $hovercard->addField(pht('Repository'), $repository); | ||||
$author = $handles[$author_phid]->renderLink(); | $author = $handles[$author_phid]->renderLink(); | ||||
if ($author_phid) { | if ($author_phid) { | ||||
$hovercard->addField(pht('Author'), $author); | $hovercard->addField(pht('Author'), $author); | ||||
} | } | ||||
if ($committer_phid && ($committer_phid !== $author_phid)) { | if ($committer_phid && ($committer_phid !== $author_phid)) { | ||||
$committer = $handles[$committer_phid]->renderLink(); | $committer = $handles[$committer_phid]->renderLink(); | ||||
$hovercard->addField(pht('Committer'), $committer); | $hovercard->addField(pht('Committer'), $committer); | ||||
} | } | ||||
$date = phabricator_date($commit->getEpoch(), $viewer); | $date = phabricator_date($commit->getEpoch(), $viewer); | ||||
$hovercard->addField(pht('Date'), $date); | $hovercard->addField(pht('Commit Date'), $date); | ||||
if (!$commit->isAuditStatusNoAudit()) { | if (!$commit->isAuditStatusNoAudit()) { | ||||
$status = $commit->getAuditStatusObject(); | $status = $commit->getAuditStatusObject(); | ||||
$hovercard->addField( | $hovercard->addField( | ||||
pht('Audit Status'), | pht('Audit Status'), | ||||
$status->getName()); | $status->getName()); | ||||
} | } | ||||
} | } | ||||
} | } |