BEGIN { extends 'Gitalist::Controller' }
sub handler : Chained('/base') PathPart('legacy') Args() {
- my ( $self, $c ) = @_;
- my $action;
+ my ( $self, $c, $repos ) = @_;
+ my ($action, @captures);
if (my $a = $c->req->param('a')) {
$a eq 'opml' && do { $action = '/opml/opml'; };
$a eq 'project_index' && do { $action = '/legacyuri/project_index'; };
- $a eq 'summary' && do { $action = '/repository/summary'; };
+ $a =~ /^(summary|heads|tags)$/ && do { $action = "/repository/$1"; push(@captures, $repos); };
}
die("Not supported") unless $action;
- $c->res->redirect($c->uri_for_action($action));
+ $c->res->redirect($c->uri_for_action($action, \@captures));
$c->res->status(301);
}
sub test {
my ($uri, $qs) = @_;
- my $request = $uri;
+ my $request = "/$uri";
+ $request =~ s{/+}{/}g;
$request .= "?$qs" if defined $qs;
my $response = request($request);
- $uri = $response->header('Location');
+ $uri = $response->header('Location') || '';
is($response->code, 301, "ok $request 301 to " . $uri)
or return $response;
$response = request($uri);
test('/', 'a=project_index');
test('/', 'a=opml');
-{
- local *test = curry_test_uri('repos1', \&test);
- local $TODO = 'FIXME';
-
+no warnings 'redefine';
+local *test = curry_test_uri('repo1', \&test);
+test('/', 'a=project_index');
+test('/', 'a=opml');
test('/', 'a=summary');
test('/', 'a=heads');
test('/', 'a=tags');
+{
+
+ local $TODO = 'FIXME';
test('/', 'a=blob;f=dir1/file2;h=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
test('/', 'a=blob;f=dir1/file2;h=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=HEAD');