X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FController%2FLegacyURI.pm;h=28407e17b5b38b57a4625e447ca4d33536089c9f;hb=a46cb1523933154490ffbb8d1b28dcda57568801;hp=597cb5b593686baace850d8111a1a123bd762c14;hpb=6565d71a358d8d2b0f36a6d30c165aebdb7bafbf;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Controller/LegacyURI.pm b/lib/Gitalist/Controller/LegacyURI.pm index 597cb5b..28407e1 100644 --- a/lib/Gitalist/Controller/LegacyURI.pm +++ b/lib/Gitalist/Controller/LegacyURI.pm @@ -26,7 +26,79 @@ my %LEGACY_DISPATCH = ( my($c, $action, $repos) = @_; my $ref = $c->req->param('hb') || $c->req->param('h'); my $compare = $c->req->param('hbp') || $c->req->param('hp'); - return '/ref/diff', [$repos, $ref], $compare, $c->req->param('f'); + return '/ref/diff_fancy', [$repos, $ref], $compare, $c->req->param('f'); + }, + blobdiff_plain => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h'); + my $compare = $c->req->param('hbp') || $c->req->param('hp'); + return '/ref/diff_plain', [$repos, $ref], $compare, $c->req->param('f'); + }, + commit => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h') || 'HEAD'; + return '/ref/commit', [$repos, $ref]; + }, + # XXX These can be consolidated with the blob equivalents. + commitdiff => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h') || 'HEAD'; + my $compare = $c->req->param('hbp') || $c->req->param('hp'); + return '/ref/diff_fancy', [$repos, $ref], $compare, $c->req->param('f'); + }, + commitdiff_plain => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h'); + my $compare = $c->req->param('hbp') || $c->req->param('hp'); + return '/ref/diff_plain', [$repos, $ref || 'HEAD'], $compare, $c->req->param('f'); + }, + history => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h') || 'HEAD'; + return '/ref/history', [$repos, $ref], $c->req->param('f'); + }, + log => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h') || 'HEAD'; + return '/ref/longlog', [$repos, $ref]; + }, + patch => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h') || 'HEAD'; + return '/ref/patch', [$repos, $ref]; + }, + patches => sub { + my($c, $action, $repos) = @_; + # XXX Is the arg there wrong? It's just copying G::C::R::patch. + return '/ref/patches', [$repos, $c->req->param('h') || 'HEAD'], 1; + }, + search_help => sub { + return '/search_help'; + }, + shortlog => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h') || 'HEAD'; + return '/ref/shortlog', [$repos, $ref]; + }, + snapshot => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('h') || 'HEAD'; + return '/ref/snapshot', [$repos, $ref], $c->req->param('sf'); + }, + tree => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h') || 'HEAD'; + return '/ref/tree', [$repos, $ref], $c->req->param('f'); + }, + '(?:atom|rss)' => sub { + my($c, $action, $repos) = @_; + # XXX No support for arbitrary branches or merges/nomerges option :( + return "/repository/$action", [$repos], $c->req->param('f'); + }, + blame => sub { + my($c, $action, $repos) = @_; + my $ref = $c->req->param('hb') || $c->req->param('h'); + return '/ref/blame', [$repos, $ref], $c->req->param('f'); }, ); @@ -40,19 +112,25 @@ sub _legacy_uri { die "Matched too many actions for '$a' - @result" if @result > 1; - return $LEGACY_DISPATCH{$result[0]}->($c, $action, $repos) - if $result[0]; + return + unless $result[0]; + + my($real_action, $captures, @args) = $LEGACY_DISPATCH{$result[0]}->($c, $action, $repos); + + return $real_action, $captures || [], grep defined, @args; } sub handler : Chained('/base') PathPart('legacy') Args() { my ( $self, $c, $repos ) = @_; + $repos ||= $c->req->param('p'); + my ($action, $captures, @args) = $self->_legacy_uri($c, $repos, $c->req->param('a')); die("Not supported") unless $action; - $c->res->redirect($c->uri_for_action($action, $captures || [], @args)); + $c->res->redirect($c->uri_for_action($action, $captures, @args)); $c->res->status(301); } @@ -62,7 +140,7 @@ sub project_index : Chained('/base') Args(0) { $c->response->content_type('text/plain'); $c->response->body( join "\n", map $_->name, $c->model()->repositories->flatten - ) or die 'No repositories found in '. $c->model->repo_dir; + ) or die 'No repositories found in ' . ref($c->model) . ' ' . $c->model->debug_string; } __PACKAGE__->meta->make_immutable;