Skip to content

Commit

Permalink
Add per line link for previous version of a line in blame.
Browse files Browse the repository at this point in the history
  • Loading branch information
lwsitu committed Dec 22, 2009
1 parent 8dce2bf commit 799c619
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Gitalist/Controller/Root.pm
Expand Up @@ -154,7 +154,7 @@ sub blame : Chained('base') Args(0) {
|| die "Couldn't discern the corresponding head.";
my $filename = $c->req->param('f') || '';

my $blame = $repository->get_object($hb)->blame($filename);
my $blame = $repository->get_object($hb)->blame($filename, $h);
$c->stash(
blame => $blame,
head => $repository->get_object($hb),
Expand Down
6 changes: 3 additions & 3 deletions lib/Gitalist/Git/Object/Commit.pm
Expand Up @@ -5,7 +5,7 @@ class Gitalist::Git::Object::Commit
extends Gitalist::Git::Object
with Gitalist::Git::Object::HasTree {
use MooseX::Types::Moose qw/Str Int Bool Maybe ArrayRef/;
use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
use MooseX::Types::Common::String qw/NonEmptySimpleStr SimpleStr/;
use Moose::Autobox;
use List::MoreUtils qw/any zip/;
our $SHA1RE = qr/[0-9a-fA-F]{40}/;
Expand Down Expand Up @@ -142,9 +142,9 @@ class Gitalist::Git::Object::Commit


# XXX A prime candidate for caching.
method blame ( NonEmptySimpleStr $filename ) {
method blame ( NonEmptySimpleStr $filename, SimpleStr $sha1 ) {
my @blameout = $self->_run_cmd_list(
blame => '-p', $self->sha1, '--', $filename
blame => '-p', $sha1 ? $sha1 : $self->sha1, '--', $filename
);

my(%commitdata, @filedata);
Expand Down
3 changes: 3 additions & 0 deletions root/_tree.tt2
Expand Up @@ -25,6 +25,9 @@
</td>
<td class='action-list'>
<a href="[% c.uri_for(theact, {h=item.sha1, hb=commit.sha1, f=fullpath}) %]">[% theact %]</a>
[% IF item.type == 'blob' %]
<a href="[% c.uri_for('blame', {h=commit.sha1, hb=commit.sha1, f=fullpath}) %]">blame</a>
[% END %]
<a href="[% c.uri_for('history', {h=item.sha1, hb=commit.sha1, f=fullpath}) %]">history</a>
[% IF item.type == 'blob' %]
<a href="[% c.uri_for('raw', {hb=commit.sha1, f=fullpath}) %]">raw</a>
Expand Down
2 changes: 1 addition & 1 deletion root/blame.tt2
Expand Up @@ -47,7 +47,7 @@
<td nowrap class='date'></td>
<td nowrap class='commit-info'></td>
[%- END -%]
<td nowrap class='lineno' style='border-right: solid 3px #[% linecolour %]; border-left: solid 3px #[% linecolour %];'><tt>[% info.meta.lineno %]</tt></td>
<td nowrap class='lineno' id='l[% info.meta.lineno %]' style='border-right: solid 3px #[% linecolour %]; border-left: solid 3px #[% linecolour %];'><tt><a href='[% c.uri_for('blame', {h=info.commit.sha1,f=filename}) %]#l[% info.meta.orig_lineno %]'>[% info.meta.lineno %]</a></tt></td>
<td nowrap class='data'><pre>[% blame_lines.${loop.index} %]</pre></td>
[% lastsha1 = info.commit.sha1 %]
</tr>
Expand Down

0 comments on commit 799c619

Please sign in to comment.