Example #1
0
File: Log.php Project: beubi/gitlib
 /**
  * @return array
  */
 public function getCommits()
 {
     $args = array('--encoding=' . StringHelper::getEncoding(), '--format=raw');
     if (null !== $this->offset) {
         $args[] = '--skip=' . (int) $this->offset;
     }
     if (null !== $this->limit) {
         $args[] = '-n';
         $args[] = (int) $this->limit;
     }
     if (null !== $this->revisions) {
         $args = array_merge($args, $this->revisions->getAsTextArray());
     } else {
         $args[] = '--all';
     }
     $args[] = '--';
     $args = array_merge($args, $this->paths);
     try {
         $output = $this->repository->run('log', $args);
     } catch (ProcessException $e) {
         throw new ReferenceNotFoundException(sprintf('Can not find revision "%s"', implode(' ', $this->revisions->getAsTextArray())), null, $e);
     }
     $parser = new Parser\LogParser();
     $parser->parse($output);
     $result = array();
     foreach ($parser->log as $commitData) {
         $hash = $commitData['id'];
         unset($commitData['id']);
         $commit = $this->repository->getCommit($hash);
         $commit->setData($commitData);
         $result[] = $commit;
     }
     return $result;
 }