@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 DiffusionInternalCommitSearchEngine
4 extends PhabricatorApplicationSearchEngine {
5
6 public function getResultTypeDescription() {
7 return pht('Diffusion Raw Commits');
8 }
9
10 public function getApplicationClassName() {
11 return PhabricatorDiffusionApplication::class;
12 }
13
14 public function newQuery() {
15 return new DiffusionCommitQuery();
16 }
17
18 protected function buildQueryFromParameters(array $map) {
19 $query = $this->newQuery();
20
21 if ($map['repositoryPHIDs']) {
22 $query->withRepositoryPHIDs($map['repositoryPHIDs']);
23 }
24
25 return $query;
26 }
27
28 protected function buildCustomSearchFields() {
29 return array(
30 id(new PhabricatorSearchDatasourceField())
31 ->setLabel(pht('Repositories'))
32 ->setKey('repositoryPHIDs')
33 ->setDatasource(new DiffusionRepositoryFunctionDatasource())
34 ->setDescription(pht('Find commits in particular repositories.')),
35 );
36 }
37
38 protected function getURI($path) {
39 return '';
40 }
41
42 protected function renderResultList(
43 array $commits,
44 PhabricatorSavedQuery $query,
45 array $handles) {
46 return null;
47 }
48
49 protected function getObjectWireFieldsForConduit(
50 $object,
51 array $field_extensions,
52 array $extension_data) {
53
54 $commit = $object;
55 $viewer = $this->requireViewer();
56
57 $repository = $commit->getRepository();
58 $identifier = $commit->getCommitIdentifier();
59
60 id(new DiffusionRepositoryClusterEngine())
61 ->setViewer($viewer)
62 ->setRepository($repository)
63 ->synchronizeWorkingCopyBeforeRead();
64
65 $ref = id(new DiffusionLowLevelCommitQuery())
66 ->setRepository($repository)
67 ->withIdentifier($identifier)
68 ->execute();
69
70 return array(
71 'ref' => $ref->newDictionary(),
72 );
73 }
74
75}