From: broquaint Date: Mon, 26 Oct 2009 22:13:43 +0000 (+0000) Subject: Now heads show up in the shortlog and the current head is marked up in the heads... X-Git-Tag: 0.000000_01~108^2~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0ee97fecd5bcbf5c315cee1988e3abd66a1b0840;hp=9dc3b9a51f9b3f6c866766bfccaf70fe1c23261a;p=catagits%2FGitalist.git Now heads show up in the shortlog and the current head is marked up in the heads list. --- diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index dc79c49..ff5efac 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -60,9 +60,12 @@ sub run_gitweb { sub _get_commit { my($self, $c) = @_; + my $h = $c->req->param('h'); + my $f = $c->req->param('f'); + # Either use the provided h(ash) parameter, the f(ile) parameter or just use HEAD. - my $hash = $c->req->param('h') - || ($c->req->param('f') ? $c->model('Git')->hash_by_path($c->req->param('f')) : '') + my $hash = ($h =~ /[^a-f0-9]/ ? $c->model('Git')->head_hash($h) : $h) + || ($f && $c->model('Git')->hash_by_path($f)) || $c->model('Git')->head_hash # XXX This could definitely use more context. || Carp::croak("Couldn't find a hash for the commit object!"); @@ -111,8 +114,10 @@ sub summary : Local { $c->stash( commit => $commit, info => $c->model('Git')->project_info($c->model('Git')->project), - log_lines => [$c->model('Git')->list_revs(rev => $commit->sha1, count => 17)], + log_lines => [$c->model('Git')->list_revs(sha1 => $commit->sha1, count => 16)], + refs => $c->model('Git')->references, heads => [$c->model('Git')->heads], + HEAD => $c->model('Git')->head_hash, action => 'summary', ); } @@ -129,6 +134,7 @@ sub heads : Local { $c->stash( commit => $self->_get_commit($c), heads => [$c->model('Git')->heads], + HEAD => $c->model('Git')->head_hash, action => 'heads', ); } @@ -208,7 +214,8 @@ sub shortlog : Local { # XXX Needs paging. $c->stash( commit => $commit, - log_lines => [$c->model('Git')->list_revs(rev => $commit->sha1)], + log_lines => [$c->model('Git')->list_revs(sha1 => $commit->sha1)], + refs => $c->model('Git')->references, action => 'shortlog', ); } diff --git a/lib/Gitalist/Model/Git.pm b/lib/Gitalist/Model/Git.pm index 953cfcb..a7165f1 100644 --- a/lib/Gitalist/Model/Git.pm +++ b/lib/Gitalist/Model/Git.pm @@ -277,14 +277,14 @@ sub dir_from_project_name { =head2 head_hash -Find the C of given (or current) project. +Find the hash of a given head (defaults to HEAD) of given (or current) project. =cut sub head_hash { - my ($self, $project) = @_; + my ($self, $head, $project) = @_; - my $output = $self->run_cmd_in($project || $self->project, qw/rev-parse --verify HEAD/ ); + my $output = $self->run_cmd_in($project || $self->project, qw/rev-parse --verify/, $head || 'HEAD' ); return unless defined $output; my ($head) = $output =~ /^($SHA1RE)$/; @@ -318,6 +318,7 @@ sub list_tree { push @ret, { mode => oct $mode, + # XXX I wonder why directories always turn up as 040000 ... modestr => $self->get_object_mode_string({mode=>oct $mode}), type => $type, object => $object, @@ -524,13 +525,13 @@ array of hashes. sub list_revs { my ($self, %args) = @_; - $args{rev} ||= $self->head_hash($args{project}); + $args{sha1} ||= $self->head_hash($args{project}); my $output = $self->run_cmd_in($args{project} || $self->project, 'rev-list', '--header', (defined $args{ count } ? "--max-count=$args{count}" : ()), (defined $args{ skip } ? "--skip=$args{skip}" : ()), - $args{rev}, + $args{sha1}, '--', ($args{file} ? $args{file} : ()), ); diff --git a/root/static/css/site.css b/root/static/css/site.css index 4d05680..d672ba2 100644 --- a/root/static/css/site.css +++ b/root/static/css/site.css @@ -35,3 +35,11 @@ div.commit-message { padding: 3px 0; font-weight: bold; } + +/* /heads */ +.heads .head { + font-weight: bold; +} +.heads .current { + text-decoration: underline; +} diff --git a/t/model_Git.t b/t/model_Git.t index 09a4552..dc069c8 100644 --- a/t/model_Git.t +++ b/t/model_Git.t @@ -31,7 +31,7 @@ is( $projectList->[0]->{name}, 'bare.git', 'list_projects has correct name for " # Liberally borrowed from rafl's gitweb my $repo = 'repo1'; -like($m->head_hash($repo), qr/^([0-9a-fA-F]{40})$/, 'get_head_hash'); +like($m->head_hash('HEAD', $repo), qr/^([0-9a-fA-F]{40})$/, 'head_hash'); { my @tree = $m->list_tree('3bc0634310b9c62222bb0e724c11ffdfb297b4ac', $repo); diff --git a/templates/_heads.tt2 b/templates/_heads.tt2 index 6d38e75..c8f4e61 100644 --- a/templates/_heads.tt2 +++ b/templates/_heads.tt2 @@ -1,4 +1,4 @@ - +
@@ -11,7 +11,7 @@ [% FOREACH head IN heads %] - + - +
age
[% head.last_change %][% head.name %][% head.name %] shortlog log diff --git a/templates/_shortlog.tt2 b/templates/_shortlog.tt2 index 8f10392..7892534 100644 --- a/templates/_shortlog.tt2 +++ b/templates/_shortlog.tt2 @@ -15,7 +15,16 @@ [% line.sha1.substr(0, 6) %] [% line.authored_time %] [% line.author.name | html %][% line.comment.substr(0, 50) | html %] + [% line.comment.substr(0, 50) | html %] + + [% FOREACH ref IN refs.${line.sha1} %] + + [% ref.replace('^(remote|head)s/', '') %] + + [% END %] + + commit commitdiff