private function getData($name) { if (isset($this->data[$name])) { return $this->data[$name]; } if ($name === 'shortHash') { $this->data['shortHash'] = trim($this->repository->run('log', array('--abbrev-commit', '--format=%h', '-n', 1, $this->revision))); return $this->data['shortHash']; } if ($name === 'tree') { $this->data['tree'] = $this->repository->getTree($this->getData('treeHash')); return $this->data['tree']; } if ($name === 'subjectMessage') { $lines = explode("\n", $this->getData('message')); $this->data['subjectMessage'] = reset($lines); return $this->data['subjectMessage']; } if ($name === 'bodyMessage') { $message = $this->getData('message'); $lines = explode("\n", $message); array_shift($lines); array_shift($lines); $data['bodyMessage'] = implode("\n", $lines); return $data['bodyMessage']; } $parser = new Parser\CommitParser(); try { $result = $this->repository->run('cat-file', array('commit', $this->revision)); } catch (ProcessException $e) { throw new ReferenceNotFoundException(sprintf('Can not find reference "%s"', $this->revision)); } $parser->parse($result); $this->data['treeHash'] = $parser->tree; $this->data['parentHashes'] = $parser->parents; $this->data['authorName'] = $parser->authorName; $this->data['authorEmail'] = $parser->authorEmail; $this->data['authorDate'] = $parser->authorDate; $this->data['committerName'] = $parser->committerName; $this->data['committerEmail'] = $parser->committerEmail; $this->data['committerDate'] = $parser->committerDate; $this->data['message'] = $parser->message; if (!isset($this->data[$name])) { throw new \InvalidArgumentException(sprintf('No data named "%s" in Commit.', $name)); } return $this->data[$name]; }