2012-08-01 01:27:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionCommitBranchesController extends DiffusionController {
|
|
|
|
|
2013-09-27 19:49:45 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$response = $this->loadDiffusionContext();
|
|
|
|
if ($response) {
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
2015-01-09 22:29:08 +01:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
2015-02-17 23:01:17 +01:00
|
|
|
$repository = $drequest->getRepository();
|
2012-08-01 01:27:48 +02:00
|
|
|
|
2016-02-16 23:25:11 +01:00
|
|
|
$branch_limit = 10;
|
|
|
|
$branches = DiffusionRepositoryRef::loadAllFromDictionaries(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.branchquery',
|
|
|
|
array(
|
|
|
|
'contains' => $drequest->getCommit(),
|
|
|
|
'limit' => $branch_limit + 1,
|
2018-06-22 00:24:43 +02:00
|
|
|
'branch' => null,
|
2016-02-16 23:25:11 +01:00
|
|
|
)));
|
|
|
|
|
|
|
|
$has_more_branches = (count($branches) > $branch_limit);
|
|
|
|
$branches = array_slice($branches, 0, $branch_limit);
|
2012-08-01 01:27:48 +02:00
|
|
|
|
|
|
|
$branch_links = array();
|
2014-01-18 01:11:04 +01:00
|
|
|
foreach ($branches as $branch) {
|
2013-01-18 03:43:35 +01:00
|
|
|
$branch_links[] = phutil_tag(
|
2012-08-01 01:27:48 +02:00
|
|
|
'a',
|
|
|
|
array(
|
2015-01-09 22:29:08 +01:00
|
|
|
'href' => $drequest->generateURI(
|
2012-08-01 01:27:48 +02:00
|
|
|
array(
|
|
|
|
'action' => 'browse',
|
2014-01-18 01:11:04 +01:00
|
|
|
'branch' => $branch->getShortName(),
|
2012-08-01 01:27:48 +02:00
|
|
|
)),
|
|
|
|
),
|
2014-01-18 01:11:04 +01:00
|
|
|
$branch->getShortName());
|
2012-08-01 01:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-02-16 23:25:11 +01:00
|
|
|
if ($has_more_branches) {
|
|
|
|
$branch_links[] = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'branches',
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
pht("More Branches\xE2\x80\xA6"));
|
|
|
|
}
|
|
|
|
|
2012-08-01 01:27:48 +02:00
|
|
|
return id(new AphrontAjaxResponse())
|
2015-05-22 09:27:56 +02:00
|
|
|
->setContent($branch_links ? implode(', ', $branch_links) : pht('None'));
|
2012-08-01 01:27:48 +02:00
|
|
|
}
|
|
|
|
}
|