From: Dan Brook Date: Mon, 1 Mar 2010 16:14:05 +0000 (+0000) Subject: Fixed the links in the history view. X-Git-Tag: 0.000006_01~1^2~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7998de1265a0e9b2bddd66ab3ee57553e2fdef6a;p=catagits%2FGitalist.git Fixed the links in the history view. This fix mostly revolves around getting 'diff to current' to JFW, as such this isn't the most elegant solution. *ahem* --- diff --git a/README b/README index 86853b2..dcdf72f 100644 --- a/README +++ b/README @@ -41,7 +41,7 @@ GETTING GITALIST The canonical repository for the master branch is: - it://git.shadowcat.co.uk/catagits/Gitalist.git + git://git.shadowcat.co.uk/catagits/Gitalist.git Gitalist is also mirrored to github, and a number of people have active forks with branches and/or new features in the master branch. @@ -83,13 +83,13 @@ INITIAL CONFIGURATION Alternatively, if you only want to set a repository directory and are otherwise happy with the default configuration, then you can set the - "GITALIST_REPOS_DIR" environment variable, or pass the "--repos_dir" - flag to any of the scripts. + "GITALIST_REPO_DIR" environment variable, or pass the "--repos_dir" flag + to any of the scripts. - GITALIST_REPOS_DIR=/home/myuser/code/git gitalist_server.pl + GITALIST_REPO_DIR=/home/myuser/code/git gitalist_server.pl gitalist_server.pl --repos_dir home/myuser/code/git - The "GITALIST_REPOS_DIR" environment variable will override the + The "GITALIST_REPO_DIR" environment variable will override the repository directory set in configuration, and will itself be overridden by he "--repos_dir" flag. diff --git a/lib/Gitalist/Controller/Fragment/Ref.pm b/lib/Gitalist/Controller/Fragment/Ref.pm index 24e8d58..c079eb0 100644 --- a/lib/Gitalist/Controller/Fragment/Ref.pm +++ b/lib/Gitalist/Controller/Fragment/Ref.pm @@ -10,13 +10,15 @@ with qw/ sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {} -after diff => sub { +sub _diff { my ($self, $c) = @_; my $commit = $c->stash->{Commit}; + my %filename = $c->stash->{filename} ? (filename => $c->stash->{filename}) : (); my($tree, $patch) = $c->stash->{Repository}->diff( commit => $commit, - parent => $c->req->param('hp') || undef, + parent => $c->stash->{parent}, patch => 1, + %filename, ); $c->stash( diff_tree => $tree, @@ -24,16 +26,19 @@ after diff => sub { # XXX Hack hack hack, see View::SyntaxHighlight blobs => [map $_->{diff}, @$patch], language => 'Diff', + %filename, ); -}; +} after diff_fancy => sub { my ($self, $c) = @_; + $self->_diff($c); $c->forward('View::SyntaxHighlight'); }; after diff_plain => sub { my ($self, $c) = @_; + $self->_diff($c); $c->response->content_type('text/plain; charset=utf-8'); }; diff --git a/lib/Gitalist/Git/Object/Commit.pm b/lib/Gitalist/Git/Object/Commit.pm index ef36f05..921fb6b 100644 --- a/lib/Gitalist/Git/Object/Commit.pm +++ b/lib/Gitalist/Git/Object/Commit.pm @@ -49,7 +49,7 @@ class Gitalist::Git::Object::Commit method diff ( Maybe[Bool] :$patch?, Maybe[NonEmptySimpleStr] :$parent?, - Maybe[NonEmptySimpleStr] :$file? + Maybe[NonEmptySimpleStr] :$filename? ) { $parent = $parent ? $parent @@ -57,7 +57,7 @@ class Gitalist::Git::Object::Commit ? $self->parent_sha1 : '-c'; my @etc = ( - ( $file ? ('--', $file) : () ), + ( $filename ? ('--', $filename) : () ), ); my @out = $self->_raw_diff( diff --git a/lib/Gitalist/Git/Repository.pm b/lib/Gitalist/Git/Repository.pm index f65eb0b..5a3fa0f 100644 --- a/lib/Gitalist/Git/Repository.pm +++ b/lib/Gitalist/Git/Repository.pm @@ -186,11 +186,11 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils { method diff ( Gitalist::Git::Object :$commit!, Bool :$patch?, Maybe[NonEmptySimpleStr] :$parent?, - NonEmptySimpleStr :$file? + NonEmptySimpleStr :$filename? ) { return $commit->diff( patch => $patch, parent => $parent, - file => $file); + filename => $filename); } method reflog (@logargs) { diff --git a/lib/Gitalist/URIStructure/Ref.pm b/lib/Gitalist/URIStructure/Ref.pm index afea1ee..659ccc0 100644 --- a/lib/Gitalist/URIStructure/Ref.pm +++ b/lib/Gitalist/URIStructure/Ref.pm @@ -24,7 +24,14 @@ sub find : Chained('base') PathPart('') CaptureArgs(1) { sub diff : Chained('find') CaptureArgs(0) {} -sub diff_fancy : Chained('diff') PathPart('') Args(0) {} +sub diff_fancy : Chained('diff') PathPart('') Args() { + my($self, $c, $comparison, @rest) = @_; + # FIXME - This ain't pretty + $c->stash->{parent} = $comparison + if $comparison; + $c->stash->{filename} = $rest[0] + if @rest; +} sub diff_plain : Chained('diff') PathPart('plain') Args(0) {} diff --git a/root/_diff.tt2 b/root/_diff.tt2 index 146f778..404de8b 100644 --- a/root/_diff.tt2 +++ b/root/_diff.tt2 @@ -2,7 +2,7 @@ [% FOREACH item IN diff %]
diff --git [%# FIXME %] - [% item.a %][% item %] + [% item.a %] [% item.b %]
diff --git a/root/_diff_tree.tt2 b/root/_diff_tree.tt2 index 792591e..eb9a845 100644 --- a/root/_diff_tree.tt2 +++ b/root/_diff_tree.tt2 @@ -32,7 +32,7 @@ %] - [% IF !line.is_new %]diff[% END %] + [% IF !line.is_new %]diff[% END %] blob [% IF !line.is_new %]history[% END %] diff --git a/root/fragment/ref/history.tt2 b/root/fragment/ref/history.tt2 index a411337..41dd259 100644 --- a/root/fragment/ref/history.tt2 +++ b/root/fragment/ref/history.tt2 @@ -33,13 +33,13 @@ [% IF filetype == 'tree' %] - tree + blob [% ELSIF filetype == 'blob' %] - blob + blob [% END %] - commitdiff + commitdiff [% IF filetype == 'blob' %] - diff to current + diff to current [% END %] diff --git a/root/ref/diff_fancy.tt2 b/root/ref/diff_fancy.tt2 index bdecf06..82a2740 100644 --- a/root/ref/diff_fancy.tt2 +++ b/root/ref/diff_fancy.tt2 @@ -9,6 +9,8 @@ [% Commit.author.name | html %]
[% time_since(Commit.authored_time) %]
- - [% subinclude('/fragment/ref/diff_fancy', c.req.captures c.req.args.to_path) %] + [% + # What I really want is @{ c.req.args } + subinclude('/fragment/' _ c.action, c.req.captures, c.req.args.0 c.req.args.1) + %]