@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DiffusionCommitBranchesController extends DiffusionController {
4
5 public function shouldAllowPublic() {
6 return true;
7 }
8
9 public function handleRequest(AphrontRequest $request) {
10 $response = $this->loadDiffusionContext();
11 if ($response) {
12 return $response;
13 }
14
15 $drequest = $this->getDiffusionRequest();
16 $repository = $drequest->getRepository();
17
18 $branch_limit = 10;
19 $branches = DiffusionRepositoryRef::loadAllFromDictionaries(
20 $this->callConduitWithDiffusionRequest(
21 'diffusion.branchquery',
22 array(
23 'contains' => $drequest->getCommit(),
24 'limit' => $branch_limit + 1,
25 'branch' => null,
26 )));
27
28 $has_more_branches = (count($branches) > $branch_limit);
29 $branches = array_slice($branches, 0, $branch_limit);
30
31 $branch_links = array();
32 foreach ($branches as $branch) {
33 $branch_links[] = phutil_tag(
34 'a',
35 array(
36 'href' => $drequest->generateURI(
37 array(
38 'action' => 'browse',
39 'branch' => $branch->getShortName(),
40 )),
41 ),
42 $branch->getShortName());
43 }
44
45 if ($has_more_branches) {
46 $branch_links[] = phutil_tag(
47 'a',
48 array(
49 'href' => $drequest->generateURI(
50 array(
51 'action' => 'branches',
52 )),
53 ),
54 pht("More Branches\xE2\x80\xA6"));
55 }
56
57 return id(new AphrontAjaxResponse())
58 ->setContent($branch_links ? implode(', ', $branch_links) : pht('None'));
59 }
60}