From: Tomas Doran Date: Wed, 20 Jan 2010 23:46:21 +0000 (+0000) Subject: Fix a load of links, and fix blob/blame/raw/history actions to (semi) work + tests X-Git-Tag: 0.000006_01~1^2~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ca06a1778cf7fcaf4650602e65f1a7e2a1129de9;p=catagits%2FGitalist.git Fix a load of links, and fix blob/blame/raw/history actions to (semi) work + tests --- diff --git a/lib/Gitalist/Controller/Commit.pm b/lib/Gitalist/Controller/Commit.pm index a2a3b49..1165bea 100644 --- a/lib/Gitalist/Controller/Commit.pm +++ b/lib/Gitalist/Controller/Commit.pm @@ -8,8 +8,9 @@ with 'Gitalist::URIStructure::Commit'; sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {} -sub blob_plain : Chained('find_blob') Does('FilenameArgs') Args() { +sub raw : Chained('find') Does('FilenameArgs') Args() { my ($self, $c) = @_; + $c->forward('find_blob'); $c->response->content_type('text/plain; charset=utf-8'); $c->response->body(delete $c->stash->{blob}); diff --git a/lib/Gitalist/URIStructure/Commit.pm b/lib/Gitalist/URIStructure/Commit.pm index c711937..584b471 100644 --- a/lib/Gitalist/URIStructure/Commit.pm +++ b/lib/Gitalist/URIStructure/Commit.pm @@ -28,7 +28,7 @@ sub commit : Chained('find') PathPart('') Args(0) {} sub tree : Chained('find') Does('FilenameArgs') Args() {} -sub find_blob : Chained('find') PathPart('') CaptureArgs(0) { +sub find_blob : Action { my ($self, $c) = @_; # FIXME - Eugh! my $h = $c->stash->{Repository}->hash_by_path($c->stash->{Commit}->sha1, $c->stash->{filename}) @@ -36,14 +36,15 @@ sub find_blob : Chained('find') PathPart('') CaptureArgs(0) { $c->stash(blob => $c->stash->{Repository}->get_object($h)->content); } -sub blob : Chained('find_blob') Does('FilenameArgs') Args() {} +sub blob : Chained('find') Does('FilenameArgs') Args() { + my ($self, $c) = @_; + $c->forward('find_blob'); +} sub blame : Chained('find') Does('FilenameArgs') Args() {} sub history : Chained('find') Does('FilenameArgs') Args() {} -sub raw : Chained('find') Does('FilenameArgs') Args() {} - sub shortlog : Chained('find') Does('FilenameArgs') Args() {} 1; diff --git a/root/_diff.tt2 b/root/_diff.tt2 index b3062eb..8577bf6 100644 --- a/root/_diff.tt2 +++ b/root/_diff.tt2 @@ -2,8 +2,8 @@ [% FOREACH item IN diff %]
diff --git - [% item.a %] - [% item.b %] + [% item.a %] + [% item.b %]
[% item.index %] diff --git a/root/_diff_tree.tt2 b/root/_diff_tree.tt2 index 2057772..afcc1db 100644 --- a/root/_diff_tree.tt2 +++ b/root/_diff_tree.tt2 @@ -32,9 +32,9 @@ %] - [% IF !line.is_new %]diff[% END %] - blob - [% IF !line.is_new %]history[% END %] + [% IF !line.is_new %]diff[% END %] + blob + [% IF !line.is_new %]history[% END %] [% END %] diff --git a/root/commit/diff_fancy.tt2 b/root/commit/diff_fancy.tt2 index 716e61a..a2ce0bd 100644 --- a/root/commit/diff_fancy.tt2 +++ b/root/commit/diff_fancy.tt2 @@ -10,5 +10,5 @@
- [% subinclude('/fragment/commit/diff_fancy', c.req.captures) %] + [% subinclude('/fragment/commit/diff_fancy', c.req.captures c.req.args.to_path) %] diff --git a/root/fragment/commit/diff_fancy.tt2 b/root/fragment/commit/diff_fancy.tt2 index bb44da2..58a3943 100644 --- a/root/fragment/commit/diff_fancy.tt2 +++ b/root/fragment/commit/diff_fancy.tt2 @@ -1,4 +1,4 @@ -[% +MOO[% # In the case of merge commits there will be no diff tree. IF diff_tree.size > 0; INCLUDE '_diff_tree.tt2'; diff --git a/root/fragment/commit/tree.tt2 b/root/fragment/commit/tree.tt2 index 16f7ae8..fc3c695 100644 --- a/root/fragment/commit/tree.tt2 +++ b/root/fragment/commit/tree.tt2 @@ -19,8 +19,8 @@ [% item.modestr %] [%- action_type = item.type == 'tree' ? 'tree' : 'blob'; - action_for_link = item.type == 'tree' ? c.action : c.controller.action_for('blob'); - blob_or_tree_link = c.uri_for(action_for_link, c.req.captures, c.req.args.to_path(item.file)) + action_for_link = item.type == 'tree' ? '/commit/tree' : '/commit/blob'; + blob_or_tree_link = c.uri_for_action(action_for_link, c.req.captures, c.req.args.to_path(item.file)) -%] [% item.file %] @@ -28,6 +28,7 @@ [% theact %] [% IF item.type == 'blob' %] + blob blame [% END %] history diff --git a/root/fragment/repository/shortlog.tt2 b/root/fragment/repository/shortlog.tt2 index fa88a3b..6008dbd 100644 --- a/root/fragment/repository/shortlog.tt2 +++ b/root/fragment/repository/shortlog.tt2 @@ -32,7 +32,7 @@ commit - commitdiff + commitdiff tree diff --git a/root/nav/actions.tt2 b/root/nav/actions.tt2 index 4ed51ee..aa3fa0e 100644 --- a/root/nav/actions.tt2 +++ b/root/nav/actions.tt2 @@ -12,7 +12,7 @@ [% IF filename %] § blob • - raw • + rawblamehistoryHEAD diff --git a/t/01app.t b/t/01app.t index 57dba80..68d3bf4 100644 --- a/t/01app.t +++ b/t/01app.t @@ -33,14 +33,15 @@ like $response->content, qr/Page not found/, 'invalid repository handled correct test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patch'); test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/1'); test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/2'); - + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/history/dir1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blame/file1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/raw/file1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blob/file1'); + TODO: { local $TODO = "FIXME"; test('search', 'type=commit&text=added'); - - test('blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); - # FIXME - What's the difference here? #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e'); #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');