mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Show repository information (and use repository identities) in commit hovercards
Summary: Ref T12164. Ref T13439. Commit hovercards don't currently show the repository. Although this is sometimes obvious from context, it isn't at other times and it's clearly useful/important. Also, use identities to render author/committer information and show committer if the committer differs from the author. Test Plan: {F6989595} Maniphest Tasks: T13439, T12164 Differential Revision: https://secure.phabricator.com/D20881
This commit is contained in:
parent
bcf15abcd3
commit
97bed35085
1 changed files with 34 additions and 9 deletions
|
@ -26,20 +26,45 @@ final class DiffusionHovercardEngineExtension
|
|||
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$author_phid = $commit->getAuthorPHID();
|
||||
if ($author_phid) {
|
||||
$author = $viewer->renderHandle($author_phid);
|
||||
} else {
|
||||
$commit_data = $commit->loadCommitData();
|
||||
$author = phutil_tag('em', array(), $commit_data->getAuthorName());
|
||||
$commit = id(new DiffusionCommitQuery())
|
||||
->setViewer($viewer)
|
||||
->needIdentities(true)
|
||||
->needCommitData(true)
|
||||
->withPHIDs(array($commit->getPHID()))
|
||||
->executeOne();
|
||||
if (!$commit) {
|
||||
return;
|
||||
}
|
||||
|
||||
$author_phid = $commit->getAuthorDisplayPHID();
|
||||
$committer_phid = $commit->getCommitterDisplayPHID();
|
||||
$repository_phid = $commit->getRepository()->getPHID();
|
||||
|
||||
$phids = array();
|
||||
$phids[] = $author_phid;
|
||||
$phids[] = $committer_phid;
|
||||
$phids[] = $repository_phid;
|
||||
|
||||
$handles = $viewer->loadHandles($phids);
|
||||
|
||||
$hovercard->setTitle($handle->getName());
|
||||
$hovercard->setDetail($commit->getSummary());
|
||||
|
||||
$repository = $handles[$repository_phid]->renderLink();
|
||||
$hovercard->addField(pht('Repository'), $repository);
|
||||
|
||||
$author = $handles[$author_phid]->renderLink();
|
||||
if ($author_phid) {
|
||||
$hovercard->addField(pht('Author'), $author);
|
||||
$hovercard->addField(pht('Date'),
|
||||
phabricator_date($commit->getEpoch(), $viewer));
|
||||
}
|
||||
|
||||
if ($committer_phid && ($committer_phid !== $author_phid)) {
|
||||
$committer = $handles[$committer_phid]->renderLink();
|
||||
$hovercard->addField(pht('Committer'), $committer);
|
||||
}
|
||||
|
||||
$date = phabricator_date($commit->getEpoch(), $viewer);
|
||||
$hovercard->addField(pht('Date'), $date);
|
||||
|
||||
if (!$commit->isAuditStatusNoAudit()) {
|
||||
$status = $commit->getAuditStatusObject();
|
||||
|
|
Loading…
Reference in a new issue