1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Update DiffusionLastModifiedController to use identities

Summary: Ref T12164. Updates another controller to use identities.

Test Plan:
Pretty ad-hoc, but loaded the main pages of several different repos with and without repo identities. I'm not totally convinced the `author` from this data structure is actually being used:
```
$return = array(
  'commit'    => $modified,
  'date'      => $date,
  'author'    => $author,
  'details'   => $details,
);
```

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12164

Differential Revision: https://secure.phabricator.com/D19580
This commit is contained in:
Austin McKinley 2018-08-17 12:23:59 -07:00
parent 438edde031
commit 5c4c593af3
4 changed files with 21 additions and 39 deletions

View file

@ -24,6 +24,7 @@ final class DiffusionBlameController extends DiffusionController {
->setViewer($viewer)
->withRepository($repository)
->withIdentifiers($identifiers)
->needIdentities(true)
->execute();
$commits = mpull($commits, null, 'getCommitIdentifier');
} else {
@ -68,10 +69,7 @@ final class DiffusionBlameController extends DiffusionController {
$handle_phids = array();
foreach ($commits as $commit) {
$author_phid = $commit->getAuthorPHID();
if ($author_phid) {
$handle_phids[] = $author_phid;
}
$handle_phids[] = $commit->getAuthorDisplayPHID();
}
foreach ($revisions as $revision) {
@ -117,7 +115,7 @@ final class DiffusionBlameController extends DiffusionController {
$author_phid = null;
if ($commit) {
$author_phid = $commit->getAuthorPHID();
$author_phid = $commit->getAuthorDisplayPHID();
}
if (!$author_phid && $revision) {

View file

@ -35,6 +35,7 @@ final class DiffusionLastModifiedController extends DiffusionController {
->withRepository($drequest->getRepository())
->withIdentifiers(array_values($modified_map))
->needCommitData(true)
->needIdentities(true)
->execute();
$commit_map = mpull($commit_map, null, 'getCommitIdentifier');
} else {
@ -54,9 +55,8 @@ final class DiffusionLastModifiedController extends DiffusionController {
$phids = array();
foreach ($commits as $commit) {
$data = $commit->getCommitData();
$phids[] = $data->getCommitDetail('authorPHID');
$phids[] = $data->getCommitDetail('committerPHID');
$phids[] = $commit->getCommitterDisplayPHID();
$phids[] = $commit->getAuthorDisplayPHID();
}
$phids = array_filter($phids);
$handles = $this->loadViewerHandles($phids);
@ -110,38 +110,21 @@ final class DiffusionLastModifiedController extends DiffusionController {
$date = '';
}
$data = $commit->getCommitData();
if ($data) {
$author_phid = $data->getCommitDetail('authorPHID');
if ($author_phid && isset($handles[$author_phid])) {
$author = $handles[$author_phid]->renderLink();
} else {
$author = DiffusionView::renderName($data->getAuthorName());
}
$author = $commit->renderAuthor($viewer, $handles);
$committer = $commit->renderCommitter($viewer, $handles);
$committer = $data->getCommitDetail('committer');
if ($committer) {
$committer_phid = $data->getCommitDetail('committerPHID');
if ($committer_phid && isset($handles[$committer_phid])) {
$committer = $handles[$committer_phid]->renderLink();
} else {
$committer = DiffusionView::renderName($committer);
}
if ($author != $committer) {
$author = hsprintf('%s/%s', $author, $committer);
}
}
$details = DiffusionView::linkDetail(
$drequest->getRepository(),
$commit->getCommitIdentifier(),
$data->getSummary());
$details = AphrontTableView::renderSingleDisplayLine($details);
} else {
$author = '';
$details = '';
if ($author != $committer) {
$author = hsprintf('%s/%s', $author, $committer);
}
$data = $commit->getCommitData();
$details = DiffusionView::linkDetail(
$drequest->getRepository(),
$commit->getCommitIdentifier(),
$data->getSummary());
$details = AphrontTableView::renderSingleDisplayLine($details);
$return = array(
'commit' => $modified,
'date' => $date,

View file

@ -39,6 +39,7 @@ final class PhabricatorRepositoryIdentityPHIDType
$handle->setObjectName(pht('Identity %d', $id));
$handle->setName($name);
$handle->setURI($identity->getURI());
$handle->setIcon('fa-user');
}
}

View file

@ -464,7 +464,7 @@ final class PhabricatorRepositoryCommit
$data = $this->getCommitData();
$committer_name = $data->getCommitDetail('committer');
if (strlen($committer_name)) {
return $committer_name;
return DiffusionView::renderName($committer_name);
}
return null;
@ -479,7 +479,7 @@ final class PhabricatorRepositoryCommit
$data = $this->getCommitData();
$author_name = $data->getAuthorName();
if (strlen($author_name)) {
return $author_name;
return DiffusionView::renderName($author_name);
}
return null;