Differential D21404 Diff 50947 src/applications/diffusion/controller/DiffusionLastModifiedController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionLastModifiedController.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | foreach ($paths as $path) { | ||||
if ($modified_at) { | if ($modified_at) { | ||||
$commit = idx($commit_map, $modified_at); | $commit = idx($commit_map, $modified_at); | ||||
if ($commit) { | if ($commit) { | ||||
$commits[$path] = $commit; | $commits[$path] = $commit; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$phids = array(); | |||||
foreach ($commits as $commit) { | |||||
$phids[] = $commit->getCommitterDisplayPHID(); | |||||
$phids[] = $commit->getAuthorDisplayPHID(); | |||||
} | |||||
$phids = array_filter($phids); | |||||
$handles = $this->loadViewerHandles($phids); | |||||
$branch = $drequest->loadBranch(); | $branch = $drequest->loadBranch(); | ||||
if ($branch && $commits) { | if ($branch && $commits) { | ||||
$lint_query = id(new DiffusionLintCountQuery()) | $lint_query = id(new DiffusionLintCountQuery()) | ||||
->withBranchIDs(array($branch->getID())) | ->withBranchIDs(array($branch->getID())) | ||||
->withPaths(array_keys($commits)); | ->withPaths(array_keys($commits)); | ||||
if ($drequest->getLint()) { | if ($drequest->getLint()) { | ||||
$lint_query->withCodes(array($drequest->getLint())); | $lint_query->withCodes(array($drequest->getLint())); | ||||
} | } | ||||
$lint = $lint_query->execute(); | $lint = $lint_query->execute(); | ||||
} else { | } else { | ||||
$lint = array(); | $lint = array(); | ||||
} | } | ||||
$output = array(); | $output = array(); | ||||
foreach ($commits as $path => $commit) { | foreach ($commits as $path => $commit) { | ||||
$prequest = clone $drequest; | $prequest = clone $drequest; | ||||
$prequest->setPath($path); | $prequest->setPath($path); | ||||
$output[$path] = $this->renderColumns( | $output[$path] = $this->renderColumns( | ||||
$prequest, | $prequest, | ||||
$handles, | |||||
$commit, | $commit, | ||||
idx($lint, $path)); | idx($lint, $path)); | ||||
} | } | ||||
return id(new AphrontAjaxResponse())->setContent($output); | return id(new AphrontAjaxResponse())->setContent($output); | ||||
} | } | ||||
private function renderColumns( | private function renderColumns( | ||||
DiffusionRequest $drequest, | DiffusionRequest $drequest, | ||||
array $handles, | |||||
PhabricatorRepositoryCommit $commit = null, | PhabricatorRepositoryCommit $commit = null, | ||||
$lint = null) { | $lint = null) { | ||||
assert_instances_of($handles, 'PhabricatorObjectHandle'); | $viewer = $this->getViewer(); | ||||
$viewer = $this->getRequest()->getUser(); | |||||
if ($commit) { | if ($commit) { | ||||
$epoch = $commit->getEpoch(); | $epoch = $commit->getEpoch(); | ||||
$modified = DiffusionView::linkCommit( | $modified = DiffusionView::linkCommit( | ||||
$drequest->getRepository(), | $drequest->getRepository(), | ||||
$commit->getCommitIdentifier()); | $commit->getCommitIdentifier()); | ||||
$date = $viewer->formatShortDateTime($epoch); | $date = $viewer->formatShortDateTime($epoch); | ||||
} else { | } else { | ||||
$modified = ''; | $modified = ''; | ||||
$date = ''; | $date = ''; | ||||
} | } | ||||
$author = $commit->renderAuthor($viewer, $handles); | |||||
$committer = $commit->renderCommitter($viewer, $handles); | |||||
if ($author != $committer) { | |||||
$author = hsprintf('%s/%s', $author, $committer); | |||||
} | |||||
$data = $commit->getCommitData(); | $data = $commit->getCommitData(); | ||||
$details = DiffusionView::linkDetail( | $details = DiffusionView::linkDetail( | ||||
$drequest->getRepository(), | $drequest->getRepository(), | ||||
$commit->getCommitIdentifier(), | $commit->getCommitIdentifier(), | ||||
$data->getSummary()); | $data->getSummary()); | ||||
$details = AphrontTableView::renderSingleDisplayLine($details); | $details = AphrontTableView::renderSingleDisplayLine($details); | ||||
$return = array( | $return = array( | ||||
'commit' => $modified, | 'commit' => $modified, | ||||
'date' => $date, | 'date' => $date, | ||||
'author' => $author, | |||||
'details' => $details, | 'details' => $details, | ||||
); | ); | ||||
if ($lint !== null) { | if ($lint !== null) { | ||||
$return['lint'] = phutil_tag( | $return['lint'] = phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $drequest->generateURI(array( | 'href' => $drequest->generateURI(array( | ||||
Show All 17 Lines |