+
+ /**
+ * Returns the history of the repository.
+ * We don't use VersionControl_Git's rev list fetcher since it does not
+ * give us separate email addresses and names, and it does not give us
+ * the amount of changed (added/deleted) lines.
+ *
+ * @return array Array of history objects
+ */
+ public function getHistory()
+ {
+ $output = $this->getVc()->getCommand('log')
+ ->setOption('pretty', 'format:commit %H%n%at%n%an%n%ae')
+ ->setOption('max-count', 10)
+ ->setOption('shortstat')
+ ->execute();
+
+ $arCommits = array();
+ $arOutput = explode("\n", $output);
+ $lines = count($arOutput);
+ $current = 0;
+ while ($current < $lines) {
+ $commit = new Repository_Commit();
+ list($name,$commit->hash) = explode(' ', $arOutput[$current]);
+ if ($name !== 'commit') {
+ throw new Exception(
+ 'Git log output format not as expected: ' . $arOutput[$current]
+ );
+ }
+ $commit->committerTime = $arOutput[$current + 1];
+ $commit->committerName = $arOutput[$current + 2];
+ $commit->committerEmail = $arOutput[$current + 3];
+
+ $arLineParts = explode(' ', trim($arOutput[$current + 4]));
+ $commit->filesChanged = $arLineParts[0];
+ $commit->linesAdded = $arLineParts[3];
+ $commit->linesDeleted = $arLineParts[5];
+
+ $current += 6;
+
+ $arCommits[] = $commit;
+ }
+
+ return $arCommits;
+ }