[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/conduit/ -> DiffusionExistsQueryConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class DiffusionExistsQueryConduitAPIMethod
   4    extends DiffusionQueryConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'diffusion.existsquery';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return 'Determine if code exists in a version control system.';
  12    }
  13  
  14    public 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      list($info) = $repository->execxRemoteCommand(
  37        'info %s',
  38        $repository->getRemoteURI());
  39      $exists = false;
  40      $matches = null;
  41      if (preg_match('/^Revision: (\d+)$/m', $info, $matches)) {
  42        $base_revision = $matches[1];
  43        $exists = $base_revision >= $commit;
  44      }
  45      return $exists;
  46    }
  47  
  48    protected function getMercurialResult(ConduitAPIRequest $request) {
  49      $repository = $this->getDiffusionRequest()->getRepository();
  50      $commit = $request->getValue('commit');
  51      list($err, $stdout) = $repository->execLocalCommand(
  52        'id --rev %s',
  53        $commit);
  54      return  !$err;
  55    }
  56  
  57  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1