... | ... |
@@ -37,3 +37,4 @@ xt/import_rep.db |
37 | 37 |
xt/import_rep_user |
38 | 38 |
xt/smart_http.db |
39 | 39 |
xt/smart_http |
40 |
+xt/smart_http_work |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
use IPC::Open3 ();; |
3 | 3 |
use Symbol (); |
4 | 4 |
use IO::Select (); |
5 |
- |
|
5 |
+ |
|
6 | 6 |
my $service = param('service') || ''; |
7 | 7 |
my $user = param('user'); |
8 | 8 |
my $project = param('project'); |
... | ... |
@@ -58,8 +58,28 @@ |
58 | 58 |
} |
59 | 59 |
# Dumb HTTP |
60 | 60 |
else { |
61 |
- $git->cmd($user, $project, 'update-server-info'); |
|
62 |
- $self->render_static("../data/rep/$user/$project.git/info/refs"); |
|
63 |
- return; |
|
61 |
+ # Update server info |
|
62 |
+ my @cmd = $git->cmd($user, $project, 'update-server-info'); |
|
63 |
+ open my $fh, '-|', @cmd |
|
64 |
+ or die "Can't open pipe for @cmd:$!"; |
|
65 |
+ close $fh |
|
66 |
+ or die "Can't close pipe for @cmd:$!"; |
|
67 |
+ |
|
68 |
+ my $rep_home = app->git->rep_home; |
|
69 |
+ my $file = Mojo::Asset::File->new(path => "$rep_home/$user/$project.git/info/refs"); |
|
70 |
+ my $content = $file->slurp; |
|
71 |
+ if (defined $content) { |
|
72 |
+ $self->res->headers->content_type('text/plain; charset=UTF-8'); |
|
73 |
+ $self->res->headers->content_length(length $content); |
|
74 |
+ $self->res->body($content); |
|
75 |
+ $self->res->code(200); |
|
76 |
+ $self->rendered; |
|
77 |
+ return; |
|
78 |
+ } |
|
79 |
+ else { |
|
80 |
+ $self->res->code(404); |
|
81 |
+ $self->rendered; |
|
82 |
+ return; |
|
83 |
+ } |
|
64 | 84 |
} |
65 | 85 |
%> |
... | ... |
@@ -15,6 +15,8 @@ |
15 | 15 |
my $rep_dir = $git->rep($user, $project); |
16 | 16 |
my @cmd = $git->cmd($user, $project, $service, '--stateless-rpc', $rep_dir); |
17 | 17 |
|
18 |
+ warn 'a'; |
|
19 |
+ |
|
18 | 20 |
# Command |
19 | 21 |
my ($cout, $cerr) = (Symbol::gensym, Symbol::gensym); |
20 | 22 |
my $pid = IPC::Open3::open3(my $cin, $cout, $cerr, @cmd); |
... | ... |
@@ -31,6 +33,8 @@ |
31 | 33 |
} |
32 | 34 |
close $cin; |
33 | 35 |
|
36 |
+ warn 'b'; |
|
37 |
+ |
|
34 | 38 |
# Response |
35 | 39 |
$self->res->headers->content_type("application/x-git-$service-result"); |
36 | 40 |
$self->render_later; |
... | ... |
@@ -41,6 +45,7 @@ |
41 | 45 |
my $buffer_size = $sh->buffer_size; |
42 | 46 |
my $cb; |
43 | 47 |
$cb = sub { |
48 |
+ warn 'c'; |
|
44 | 49 |
my $c = shift; |
45 | 50 |
if (my @ready = $s->can_read) { |
46 | 51 |
my $error; |
... | ... |
@@ -31,6 +31,7 @@ use Gitprep; |
31 | 31 |
note 'Smart HTTP'; |
32 | 32 |
{ |
33 | 33 |
unlink $db_file; |
34 |
+ rmtree $rep_home; |
|
34 | 35 |
|
35 | 36 |
my $app = Gitprep->new; |
36 | 37 |
my $t = Test::Mojo->new($app); |
... | ... |
@@ -47,6 +48,27 @@ note 'Smart HTTP'; |
47 | 48 |
# Create user |
48 | 49 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'}); |
49 | 50 |
$t->content_like(qr/Success.*created/); |
51 |
+ |
|
52 |
+ # Login as kimoto |
|
53 |
+ $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'}); |
|
54 |
+ $t->get_ok('/')->content_like(qr/kimoto/); |
|
55 |
+ |
|
56 |
+ # Create repository |
|
57 |
+ $t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello', readme => 1}); |
|
58 |
+ $t->content_like(qr/README/); |
|
59 |
+ |
|
60 |
+ # info/refs |
|
61 |
+ $t->get_ok("/kimoto/t1.git/info/refs"); |
|
62 |
+ $t->status_is(200); |
|
63 |
+ $t->content_type_is('text/plain; charset=UTF-8'); |
|
64 |
+ |
|
65 |
+=pod |
|
66 |
+ # Loose object |
|
67 |
+ $t->get_ok("/kimoto/t1.git/objects/20/42336f878dd054083193909140d1d10c16e775"); |
|
68 |
+ $t->status_is(200); |
|
69 |
+ $t->content_type_is('application/x-git-loose-object'); |
|
70 |
+=cut |
|
71 |
+ |
|
50 | 72 |
|
51 | 73 |
|
52 | 74 |
} |