diff --git a/src/IDF/Git.php b/src/IDF/Git.php index 5c460c1..09a3791 100644 --- a/src/IDF/Git.php +++ b/src/IDF/Git.php @@ -228,7 +228,7 @@ class IDF_Git } } $out = self::parseLog($log, 4); - $out[0]->changes = $change; + $out[0]->changes = implode("\n", $change); return $out[0]; } diff --git a/src/IDF/Template/IssueComment.php b/src/IDF/Template/IssueComment.php index 223b917..b9608ba 100644 --- a/src/IDF/Template/IssueComment.php +++ b/src/IDF/Template/IssueComment.php @@ -88,7 +88,7 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag return $m[0]; } $co = $this->git->getCommit($m[2]); - return ''.$m[1].$m[2].''; + return ''.$m[1].$m[2].''; } /** diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index 8b41c9e..67628f4 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -145,6 +145,40 @@ class IDF_Views_Source } return ' '; } + + public function commit($request, $match) + { + + $git = new IDF_Git(Pluf::f('git_repository')); + $commit = $match[2]; + $branches = $git->getBranches(); + if ('commit' != $git->testHash($commit)) { + // Redirect to the first branch + $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase', + array($request->project->shortname, + $branches[0])); + return new Pluf_HTTP_Response_Redirect($url); + } + $title = sprintf('%s Commit Details', (string) $request->project); + $page_title = sprintf('%s Commit Details - %s', (string) $request->project, $commit); + $cobject = $git->getCommit($commit); + require_once 'Text/Highlighter.php'; + $th = new Text_Highlighter(); + $h = $th->factory('DIFF'); + $changes = $h->highlight($cobject->changes); + return Pluf_Shortcuts_RenderToResponse('source/commit.html', + array( + 'page_title' => $page_title, + 'title' => $title, + 'changes' => $changes, + 'cobject' => $cobject, + 'commit' => $commit, + 'branches' => $branches, + ), + $request); + } + + } function IDF_Views_Source_PrettySize($size) diff --git a/src/IDF/conf/views.php b/src/IDF/conf/views.php index d9a372a..eccd4dc 100644 --- a/src/IDF/conf/views.php +++ b/src/IDF/conf/views.php @@ -116,6 +116,12 @@ $ctl[] = array('regex' => '#^/p/(\w+)/source/changes/(\w+)/$#', 'model' => 'IDF_Views_Source', 'method' => 'changeLog'); +$ctl[] = array('regex' => '#^/p/(\w+)/source/commit/(\w+)/$#', + 'base' => $base, + 'priority' => 4, + 'model' => 'IDF_Views_Source', + 'method' => 'commit'); + // ---------- ADMIN -------------------------------------- diff --git a/src/IDF/templates/source/base.html b/src/IDF/templates/source/base.html index 9c9e97a..fec2832 100644 --- a/src/IDF/templates/source/base.html +++ b/src/IDF/templates/source/base.html @@ -4,6 +4,7 @@
{trans 'Date:'} | {$cobject.date|date:"%Y-%m-%d %H:%M:%S"} ({$cobject.date|dateago}) | +
---|---|
{trans 'Author:'} | {$cobject.author|strip_tags} | +
{trans 'Commit:'} | {$cobject.commit} | +
{trans 'Tree:'} | {$cobject.tree} |
+
{trans 'Message:'} | {issuetext $cobject.title, $project}{if isset($cobject.full_message)} {issuetext $cobject.full_message, $project}{/if} |
+
{trans 'Branches:'}
+{foreach $branches as $branch}
+{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
+{$branch}
+{/foreach}
+