[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/query/filecontent/ -> DiffusionGitFileContentQuery.php (source)

   1  <?php
   2  
   3  final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery {
   4  
   5    public function getFileContentFuture() {
   6      $drequest = $this->getRequest();
   7  
   8      $repository = $drequest->getRepository();
   9      $path = $drequest->getPath();
  10      $commit = $drequest->getCommit();
  11  
  12      if ($this->getNeedsBlame()) {
  13        return $repository->getLocalCommandFuture(
  14          '--no-pager blame -c -l --date=short %s -- %s',
  15          $commit,
  16          $path);
  17      } else {
  18        return $repository->getLocalCommandFuture(
  19          'cat-file blob %s:%s',
  20          $commit,
  21          $path);
  22      }
  23    }
  24  
  25    protected function executeQueryFromFuture(Future $future) {
  26      list($corpus) = $future->resolvex();
  27  
  28      $file_content = new DiffusionFileContent();
  29      $file_content->setCorpus($corpus);
  30  
  31      return $file_content;
  32    }
  33  
  34    protected function tokenizeLine($line) {
  35      return self::match($line);
  36    }
  37  
  38    public static function match($line) {
  39      $m = array();
  40      // sample lines:
  41      //
  42      // d1b4fcdd2a7c8c0f8cbdd01ca839d992135424dc
  43      //                       (     hzhao   2009-05-01  202)function print();
  44      //
  45      // 8220d5d54f6d5d5552a636576cbe9c35f15b65b2
  46      //                       (Andrew Gallagher       2010-12-03      324)
  47      //                             // Add the lines for trailing context
  48      preg_match('/^\s*?(\S+?)\s*\(\s*(.*?)\s+\d{4}-\d{2}-\d{2}\s+\d+\)(.*)?$/',
  49                 $line, $m);
  50      $rev_id = $m[1];
  51      $author = $m[2];
  52      $text = idx($m, 3);
  53      return array($rev_id, $author, $text);
  54    }
  55  
  56  }


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