+ $link = $this->id . '/delete/confirm';
+ } else if ($type == 'remotefork') {
+ return 'web+fork:' . $this->getLink('display', null, true);
+ } else if ($type == 'revision') {
+ $link = $this->id . '/rev/' . $option;
+ } else if ($type == 'linkback') {
+ $link = $this->id . '/linkback';
+ } else {
+ throw new Exception('Unknown link type');
+ }
+
+ if ($full) {
+ $link = Tools::fullUrl($link);
+ }
+ return $link;
+ }
+
+ public function getCloneURL($public = true)
+ {
+ $var = $public ? 'public' : 'private';
+ if (isset($GLOBALS['phorkie']['cfg']['git'][$var])) {
+ return $GLOBALS['phorkie']['cfg']['git'][$var] . $this->id . '.git';
+ }
+ return null;
+ }
+
+ /**
+ * 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];
+
+ if (substr($arOutput[$current + 4], 0, 1) != ' ') {
+ //commit without changed lines
+ $arCommits[] = $commit;
+ $current += 4;
+ continue;
+ }
+
+ $arLineParts = explode(' ', trim($arOutput[$current + 4]));
+ $commit->filesChanged = $arLineParts[0];
+ $commit->linesAdded = $arLineParts[3];
+ if (isset($arLineParts[5])) {
+ $commit->linesDeleted = $arLineParts[5];
+ }
+
+ $current += 6;
+
+ $arCommits[] = $commit;