Clean up Diffusion branch query a bit
Summary: Ref T2716. - Serve from `DiffusionCommitQuery`, not `PhabricatorAuditCommitQuery` (which should probably die). - Fix logic for `limit`, which incorrectly failed to display the "Showing %d branches." text. - Clean up things a touch. - I didn't end up actually needing `needCommitData()`, but left it in there since I think it will be needed soon. - Removed a "TODO" because I don't remember what "etc etc" means. Test Plan: Looked at branches in several repositories. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2716 Differential Revision: https://secure.phabricator.com/D7451
This commit is contained in:
@@ -198,61 +198,62 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||
}
|
||||
|
||||
private function buildBranchListTable(DiffusionRequest $drequest) {
|
||||
if ($drequest->getBranch() !== null) {
|
||||
$limit = 15;
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$branches = DiffusionBranchInformation::newFromConduit(
|
||||
$this->callConduitWithDiffusionRequest(
|
||||
'diffusion.branchquery',
|
||||
array(
|
||||
'limit' => $limit
|
||||
)));
|
||||
if (!$branches) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$more_branches = (count($branches) > $limit);
|
||||
$branches = array_slice($branches, 0, $limit);
|
||||
|
||||
$commits = id(new PhabricatorAuditCommitQuery())
|
||||
->withIdentifiers(
|
||||
$drequest->getRepository()->getID(),
|
||||
mpull($branches, 'getHeadCommitIdentifier'))
|
||||
->needCommitData(true)
|
||||
->execute();
|
||||
|
||||
$table = new DiffusionBranchTableView();
|
||||
$table->setDiffusionRequest($drequest);
|
||||
$table->setBranches($branches);
|
||||
$table->setCommits($commits);
|
||||
$table->setUser($this->getRequest()->getUser());
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader(pht('Branches'));
|
||||
$panel->setNoBackground();
|
||||
|
||||
if ($more_branches) {
|
||||
$panel->setCaption(pht('Showing %d branches.', $limit));
|
||||
}
|
||||
|
||||
$panel->addButton(
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'branches',
|
||||
)),
|
||||
'class' => 'grey button',
|
||||
),
|
||||
pht("Show All Branches \xC2\xBB")));
|
||||
|
||||
$panel->appendChild($table);
|
||||
|
||||
return $panel;
|
||||
if ($drequest->getBranch() === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
$limit = 15;
|
||||
|
||||
$branches = DiffusionBranchInformation::newFromConduit(
|
||||
$this->callConduitWithDiffusionRequest(
|
||||
'diffusion.branchquery',
|
||||
array(
|
||||
'limit' => $limit + 1,
|
||||
)));
|
||||
if (!$branches) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$more_branches = (count($branches) > $limit);
|
||||
$branches = array_slice($branches, 0, $limit);
|
||||
|
||||
$commits = id(new DiffusionCommitQuery())
|
||||
->setViewer($viewer)
|
||||
->withIdentifiers(mpull($branches, 'getHeadCommitIdentifier'))
|
||||
->withRepositoryIDs(array($drequest->getRepository()->getID()))
|
||||
->execute();
|
||||
|
||||
$table = new DiffusionBranchTableView();
|
||||
$table->setDiffusionRequest($drequest);
|
||||
$table->setBranches($branches);
|
||||
$table->setCommits($commits);
|
||||
$table->setUser($this->getRequest()->getUser());
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader(pht('Branches'));
|
||||
$panel->setNoBackground();
|
||||
|
||||
if ($more_branches) {
|
||||
$panel->setCaption(pht('Showing %d branches.', $limit));
|
||||
}
|
||||
|
||||
$panel->addButton(
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'branches',
|
||||
)),
|
||||
'class' => 'grey button',
|
||||
),
|
||||
pht("Show All Branches \xC2\xBB")));
|
||||
|
||||
$panel->appendChild($table);
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
private function buildTagListTable(DiffusionRequest $drequest) {
|
||||
|
||||
Reference in New Issue
Block a user