mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 12:42:43 +01:00
8ab8c390b7
Summary: Ref T13151. See PHI720. If you want to test if commit X appears on specific branch Y, `git branch --contains X -- Y` is faster than (effectively) `git branch --contains X | grep Y`. Since this call has a "branch" parameter anyway, use it as the pattern argument if provided. Test Plan: - Called the API method with no parameters, got all branches. - Called the API method with `master`, got just master. - Called the API method with `maste*`, got master. This behavior is not officially supported and may change in the future. - Viewed a commit, still saw all branches. - Grepped for `diffusion.branchquery` and verified that no remaining callsites pass a default "branch" parameter. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13151 Differential Revision: https://secure.phabricator.com/D19499
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
final class DiffusionCommitBranchesController extends DiffusionController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContext();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
$repository = $drequest->getRepository();
|
|
|
|
$branch_limit = 10;
|
|
$branches = DiffusionRepositoryRef::loadAllFromDictionaries(
|
|
$this->callConduitWithDiffusionRequest(
|
|
'diffusion.branchquery',
|
|
array(
|
|
'contains' => $drequest->getCommit(),
|
|
'limit' => $branch_limit + 1,
|
|
'branch' => null,
|
|
)));
|
|
|
|
$has_more_branches = (count($branches) > $branch_limit);
|
|
$branches = array_slice($branches, 0, $branch_limit);
|
|
|
|
$branch_links = array();
|
|
foreach ($branches as $branch) {
|
|
$branch_links[] = phutil_tag(
|
|
'a',
|
|
array(
|
|
'href' => $drequest->generateURI(
|
|
array(
|
|
'action' => 'browse',
|
|
'branch' => $branch->getShortName(),
|
|
)),
|
|
),
|
|
$branch->getShortName());
|
|
}
|
|
|
|
if ($has_more_branches) {
|
|
$branch_links[] = phutil_tag(
|
|
'a',
|
|
array(
|
|
'href' => $drequest->generateURI(
|
|
array(
|
|
'action' => 'branches',
|
|
)),
|
|
),
|
|
pht("More Branches\xE2\x80\xA6"));
|
|
}
|
|
|
|
return id(new AphrontAjaxResponse())
|
|
->setContent($branch_links ? implode(', ', $branch_links) : pht('None'));
|
|
}
|
|
}
|