@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Diffusion - move build refs to occur over Conduit

Summary: Ref T2784.

Test Plan: loaded up a git commit with refs and they showed up! loaded up a git commit without revs and nothing showed up.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2784

Differential Revision: https://secure.phabricator.com/D5957

+68 -30
+2
src/__phutil_library_map__.php
··· 157 157 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php', 158 158 'ConduitAPI_diffusion_lastmodifiedquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_lastmodifiedquery_Method.php', 159 159 'ConduitAPI_diffusion_rawdiffquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_rawdiffquery_Method.php', 160 + 'ConduitAPI_diffusion_refsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_refsquery_Method.php', 160 161 'ConduitAPI_diffusion_searchquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_searchquery_Method.php', 161 162 'ConduitAPI_diffusion_stablecommitnamequery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_stablecommitnamequery_Method.php', 162 163 'ConduitAPI_diffusion_tagsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_tagsquery_Method.php', ··· 1961 1962 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPI_diffusion_Method', 1962 1963 'ConduitAPI_diffusion_lastmodifiedquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 1963 1964 'ConduitAPI_diffusion_rawdiffquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 1965 + 'ConduitAPI_diffusion_refsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 1964 1966 'ConduitAPI_diffusion_searchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 1965 1967 'ConduitAPI_diffusion_stablecommitnamequery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 1966 1968 'ConduitAPI_diffusion_tagsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
+57
src/applications/diffusion/conduit/ConduitAPI_diffusion_refsquery_Method.php
··· 1 + <?php 2 + 3 + /** 4 + * @group conduit 5 + */ 6 + final class ConduitAPI_diffusion_refsquery_Method 7 + extends ConduitAPI_diffusion_abstractquery_Method { 8 + 9 + public function getMethodDescription() { 10 + return 11 + 'Query a git repository for ref information at a specific commit.'; 12 + } 13 + 14 + public function defineReturnType() { 15 + return 'array'; 16 + } 17 + 18 + protected function defineCustomParamTypes() { 19 + return array( 20 + 'commit' => 'required string', 21 + ); 22 + } 23 + 24 + protected function getGitResult(ConduitAPIRequest $request) { 25 + $drequest = $this->getDiffusionRequest(); 26 + $repository = $drequest->getRepository(); 27 + $commit = $request->getValue('commit'); 28 + 29 + list($stdout) = $repository->execxLocalCommand( 30 + 'log --format=%s -n 1 %s --', 31 + '%d', 32 + $commit); 33 + 34 + // %d, gives a weird output format 35 + // similar to (remote/one, remote/two, remote/three) 36 + $refs = trim($stdout, "() \n"); 37 + if (!$refs) { 38 + return null; 39 + } 40 + $refs = explode(',', $refs); 41 + $refs = array_map('trim', $refs); 42 + 43 + $ref_links = array(); 44 + foreach ($refs as $ref) { 45 + $ref_links[] = array( 46 + 'ref' => $ref, 47 + 'href' => $drequest->generateURI( 48 + array( 49 + 'action' => 'browse', 50 + 'branch' => $ref, 51 + ))); 52 + } 53 + 54 + return $ref_links; 55 + } 56 + 57 + }
+9 -30
src/applications/diffusion/controller/DiffusionCommitController.php
··· 902 902 } 903 903 904 904 private function buildRefs(DiffusionRequest $request) { 905 - // Not turning this into a proper Query class since it's pretty simple, 906 - // one-off, and Git-specific. 907 - 905 + // this is git-only, so save a conduit round trip and just get out of 906 + // here if the repository isn't git 908 907 $type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT; 909 - 910 908 $repository = $request->getRepository(); 911 909 if ($repository->getVersionControlSystem() != $type_git) { 912 910 return null; 913 911 } 914 912 915 - list($stdout) = $repository->execxLocalCommand( 916 - 'log --format=%s -n 1 %s --', 917 - '%d', 918 - $request->getCommit()); 919 - 920 - // %d, gives a weird output format 921 - // similar to (remote/one, remote/two, remote/three) 922 - $refs = trim($stdout, "() \n"); 923 - if (!$refs) { 924 - return null; 925 - } 926 - $refs = explode(',', $refs); 927 - $refs = array_map('trim', $refs); 928 - 913 + $results = $this->callConduitWithDiffusionRequest( 914 + 'diffusion.refsquery', 915 + array('commit' => $request->getCommit())); 929 916 $ref_links = array(); 930 - foreach ($refs as $ref) { 931 - $ref_links[] = phutil_tag( 932 - 'a', 933 - array( 934 - 'href' => $request->generateURI( 935 - array( 936 - 'action' => 'browse', 937 - 'branch' => $ref, 938 - )), 939 - ), 940 - $ref); 917 + foreach ($results as $ref_data) { 918 + $ref_links[] = phutil_tag('a', 919 + array('href' => $ref_data['href']), 920 + $ref_data['ref']); 941 921 } 942 - 943 922 return phutil_implode_html(', ', $ref_links); 944 923 } 945 924