@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
at upstream/main 54 lines 1.4 kB view raw
1<?php 2 3final class DiffusionExistsQueryConduitAPIMethod 4 extends DiffusionQueryConduitAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'diffusion.existsquery'; 8 } 9 10 public function getMethodDescription() { 11 return pht('Determine if code exists in a version control system.'); 12 } 13 14 protected function defineReturnType() { 15 return 'bool'; 16 } 17 18 protected function defineCustomParamTypes() { 19 return array( 20 'commit' => 'required string', 21 ); 22 } 23 24 protected function getGitResult(ConduitAPIRequest $request) { 25 $repository = $this->getDiffusionRequest()->getRepository(); 26 $commit = $request->getValue('commit'); 27 list($err, $merge_base) = $repository->execLocalCommand( 28 'cat-file -t -- %s', 29 $commit); 30 return !$err; 31 } 32 33 protected function getSVNResult(ConduitAPIRequest $request) { 34 $repository = $this->getDiffusionRequest()->getRepository(); 35 $commit = $request->getValue('commit'); 36 37 $refs = id(new DiffusionCachedResolveRefsQuery()) 38 ->setRepository($repository) 39 ->withRefs(array($commit)) 40 ->execute(); 41 42 return (bool)$refs; 43 } 44 45 protected function getMercurialResult(ConduitAPIRequest $request) { 46 $repository = $this->getDiffusionRequest()->getRepository(); 47 $commit = $request->getValue('commit'); 48 list($err, $stdout) = $repository->execLocalCommand( 49 'id --rev %s', 50 hgsprintf('%s', $commit)); 51 return !$err; 52 } 53 54}