... | ... |
@@ -1,8 +1,7 @@ |
1 | 1 |
1.4 |
2 | 2 |
- fix markdown bugs (*em*, _em_) |
3 | 3 |
- default readme file is changed. README is changed to README.md |
4 |
- - add private repository and collaborator feature |
|
5 |
- - add project encoding support |
|
4 |
+ - add private repository feature |
|
6 | 5 |
1.3 |
7 | 6 |
- add README.md support |
8 | 7 |
- add submodule support |
... | ... |
@@ -18,12 +18,14 @@ use Validator::Custom; |
18 | 18 |
eval {require Digest::SHA; import Digest::SHA qw(sha1 sha1_hex)}; |
19 | 19 |
} |
20 | 20 |
|
21 |
-our $VERSION = '1.04'; |
|
21 |
+our $VERSION = '1.0301'; |
|
22 | 22 |
|
23 | 23 |
has 'dbi'; |
24 |
+has 'git'; |
|
24 | 25 |
has 'manager'; |
25 | 26 |
has 'validator'; |
26 |
-has 'git'; |
|
27 |
+ |
|
28 |
+use constant BUFFER_SIZE => 8192; |
|
27 | 29 |
|
28 | 30 |
sub startup { |
29 | 31 |
my $self = shift; |
... | ... |
@@ -43,7 +45,7 @@ sub startup { |
43 | 45 |
$listen = [split /,/, $listen] unless ref $listen eq 'ARRAY'; |
44 | 46 |
$conf->{hypnotoad}{listen} = $listen; |
45 | 47 |
|
46 |
- # Git settings |
|
48 |
+ # Git |
|
47 | 49 |
my $git = Gitprep::Git->new; |
48 | 50 |
my $git_bin |
49 | 51 |
= $conf->{basic}{git_bin} ? $conf->{basic}{git_bin} : $git->search_bin; |
... | ... |
@@ -55,20 +57,23 @@ sub startup { |
55 | 57 |
croak $error; |
56 | 58 |
} |
57 | 59 |
$git->bin($git_bin); |
58 |
- |
|
60 |
+ |
|
61 |
+ # Repository Manager |
|
62 |
+ my $manager = Gitprep::Manager->new(app => $self); |
|
63 |
+ weaken $manager->{app}; |
|
64 |
+ $self->manager($manager); |
|
65 |
+ |
|
59 | 66 |
# Repository home |
60 | 67 |
my $rep_home = $ENV{GITPREP_REP_HOME} || $self->home->rel_file('data/rep'); |
68 |
+ $git->rep_home($rep_home); |
|
61 | 69 |
unless (-d $rep_home) { |
62 | 70 |
mkdir $rep_home |
63 | 71 |
or croak "Can't create directory $rep_home: $!"; |
64 | 72 |
} |
65 |
- $git->rep_home($rep_home); |
|
66 | 73 |
$self->git($git); |
67 | 74 |
|
68 |
- # Repository Manager |
|
69 |
- my $manager = Gitprep::Manager->new(app => $self, git => $git); |
|
70 |
- weaken $manager->{app}; |
|
71 |
- $self->manager($manager); |
|
75 |
+ # Added public path |
|
76 |
+ # push @{$self->static->paths}, $rep_home; |
|
72 | 77 |
|
73 | 78 |
# DBI |
74 | 79 |
my $db_file = $ENV{GITPREP_DB_FILE} |
... | ... |
@@ -237,10 +242,10 @@ sub startup { |
237 | 242 |
|
238 | 243 |
# API |
239 | 244 |
my $api = $self->gitprep_api; |
240 |
- my $user = $self->param('user'); |
|
241 |
- my $project = $self->param('project'); |
|
242 | 245 |
|
243 | 246 |
# Private |
247 |
+ my $user = $self->param('user'); |
|
248 |
+ my $project = $self->param('project'); |
|
244 | 249 |
my $private = $self->app->manager->is_private_project($user, $project); |
245 | 250 |
if ($private) { |
246 | 251 |
if ($api->can_access_private_project($user, $project)) { |
... | ... |
@@ -42,26 +42,6 @@ sub check_user_and_password { |
42 | 42 |
return $is_valid; |
43 | 43 |
} |
44 | 44 |
|
45 |
-sub git { |
|
46 |
- my $self = shift; |
|
47 |
- |
|
48 |
- my $git = $self->app->git->clone; |
|
49 |
- |
|
50 |
- my $user = $self->cntl->param('user'); |
|
51 |
- my $project = $self->cntl->param('project'); |
|
52 |
- |
|
53 |
- if (defined $user && defined $project){ |
|
54 |
- # Project encoding |
|
55 |
- my $encoding = $self->app->dbi->model('project')->select( |
|
56 |
- 'encoding', |
|
57 |
- id => [$user, $project] |
|
58 |
- )->value; |
|
59 |
- $git->encoding($encoding) if length $encoding; |
|
60 |
- } |
|
61 |
- |
|
62 |
- return $git; |
|
63 |
-} |
|
64 |
- |
|
65 | 45 |
sub is_collaborator { |
66 | 46 |
my ($self, $user, $project, $session_user) = @_; |
67 | 47 |
|
... | ... |
@@ -78,7 +58,6 @@ sub can_access_private_project { |
78 | 58 |
my ($self, $user, $project) = @_; |
79 | 59 |
|
80 | 60 |
my $session_user = $self->cntl->session('user'); |
81 |
- return unless $session_user; |
|
82 | 61 |
|
83 | 62 |
my $is_valid = |
84 | 63 |
($user eq $session_user || $self->is_collaborator($user, $project)) |
... | ... |
@@ -87,15 +66,6 @@ sub can_access_private_project { |
87 | 66 |
return $is_valid; |
88 | 67 |
} |
89 | 68 |
|
90 |
-sub manager { |
|
91 |
- my $self = shift; |
|
92 |
- |
|
93 |
- my $manager = $self->app->manager->clone; |
|
94 |
- $manager->git($self->git); |
|
95 |
- |
|
96 |
- return $manager; |
|
97 |
-} |
|
98 |
- |
|
99 | 69 |
sub new { |
100 | 70 |
my ($class, $cntl) = @_; |
101 | 71 |
|
... | ... |
@@ -53,18 +53,6 @@ sub branch_status { |
53 | 53 |
return $status; |
54 | 54 |
} |
55 | 55 |
|
56 |
-sub clone { |
|
57 |
- my $self = shift; |
|
58 |
- |
|
59 |
- my $clone = __PACKAGE__->new; |
|
60 |
- $clone->bin($self->bin); |
|
61 |
- $clone->encoding($self->encoding); |
|
62 |
- $clone->rep_home($self->rep_home); |
|
63 |
- $clone->text_exts([@{$self->text_exts}]); |
|
64 |
- |
|
65 |
- return $clone; |
|
66 |
-} |
|
67 |
- |
|
68 | 56 |
sub no_merged_branch_h { |
69 | 57 |
my ($self, $user, $project) = @_; |
70 | 58 |
|
... | ... |
@@ -559,7 +547,7 @@ sub description { |
559 | 547 |
else { |
560 | 548 |
# Read description |
561 | 549 |
return unless -f $file; |
562 |
- my $description = $self->_dec($self->_slurp($file) || '', 'UTF-8'); |
|
550 |
+ my $description = $self->_dec($self->_slurp($file) || ''); |
|
563 | 551 |
return $description; |
564 | 552 |
} |
565 | 553 |
} |
... | ... |
@@ -1669,9 +1657,9 @@ sub _chop_str { |
1669 | 1657 |
} |
1670 | 1658 |
|
1671 | 1659 |
sub _dec { |
1672 |
- my ($self, $str, $encoding) = @_; |
|
1660 |
+ my ($self, $str) = @_; |
|
1673 | 1661 |
|
1674 |
- my $enc = $encoding || $self->encoding; |
|
1662 |
+ my $enc = $self->encoding; |
|
1675 | 1663 |
|
1676 | 1664 |
my $new_str; |
1677 | 1665 |
eval { $new_str = decode($enc, $str) }; |
... | ... |
@@ -1679,6 +1667,14 @@ sub _dec { |
1679 | 1667 |
return $@ ? $str : $new_str; |
1680 | 1668 |
} |
1681 | 1669 |
|
1670 |
+sub _enc { |
|
1671 |
+ my ($self, $str) = @_; |
|
1672 |
+ |
|
1673 |
+ my $enc = $self->encoding; |
|
1674 |
+ |
|
1675 |
+ return encode($enc, $str); |
|
1676 |
+} |
|
1677 |
+ |
|
1682 | 1678 |
sub _mode_str { |
1683 | 1679 |
my $self = shift; |
1684 | 1680 |
my $mode = oct shift; |
... | ... |
@@ -8,7 +8,6 @@ use File::Path qw/mkpath rmtree/; |
8 | 8 |
use File::Temp (); |
9 | 9 |
|
10 | 10 |
has 'app'; |
11 |
-has 'git'; |
|
12 | 11 |
|
13 | 12 |
sub admin_user { |
14 | 13 |
my $self = shift; |
... | ... |
@@ -20,16 +19,6 @@ sub admin_user { |
20 | 19 |
return $admin_user; |
21 | 20 |
} |
22 | 21 |
|
23 |
-sub clone { |
|
24 |
- my $self = shift; |
|
25 |
- |
|
26 |
- my $clone = __PACKAGE__->new; |
|
27 |
- $clone->app($self->app); |
|
28 |
- $clone->git($self->git); |
|
29 |
- |
|
30 |
- return $clone; |
|
31 |
-} |
|
32 |
- |
|
33 | 22 |
sub default_branch { |
34 | 23 |
my ($self, $user, $project, $default_branch) = @_; |
35 | 24 |
|
... | ... |
@@ -61,12 +50,8 @@ sub fork_project { |
61 | 50 |
$dbi->connector->txn(sub { |
62 | 51 |
|
63 | 52 |
# Original project id |
64 |
- my $project_info = $dbi->model('project')->select( |
|
65 |
- ['original_pid', 'private', 'encoding'], |
|
66 |
- id => [$original_user, $project] |
|
67 |
- )->one; |
|
68 |
- |
|
69 |
- my $original_pid = $project_info->{original_pid}; |
|
53 |
+ my $original_pid = $dbi->model('project') |
|
54 |
+ ->select('original_pid', id => [$original_user, $project])->value; |
|
70 | 55 |
|
71 | 56 |
croak "Can't get original project id" |
72 | 57 |
unless defined $original_pid && $original_pid > 0; |
... | ... |
@@ -78,9 +63,7 @@ sub fork_project { |
78 | 63 |
$project, |
79 | 64 |
{ |
80 | 65 |
original_user => $original_user, |
81 |
- original_pid => $original_pid, |
|
82 |
- private => $project_info->{private}, |
|
83 |
- encoding => $project_info->{encoding} |
|
66 |
+ original_pid => $original_pid |
|
84 | 67 |
} |
85 | 68 |
); |
86 | 69 |
}; |
... | ... |
@@ -283,7 +266,7 @@ sub rename_project { |
283 | 266 |
my ($self, $user, $project, $to_project) = @_; |
284 | 267 |
|
285 | 268 |
# Rename project |
286 |
- my $git = $self->git; |
|
269 |
+ my $git = $self->app->git; |
|
287 | 270 |
my $dbi = $self->app->dbi; |
288 | 271 |
my $error; |
289 | 272 |
eval { |
... | ... |
@@ -349,8 +332,7 @@ EOS |
349 | 332 |
"default_branch not null default 'master'", |
350 | 333 |
"original_user not null default ''", |
351 | 334 |
"original_pid integer not null default 0", |
352 |
- "private not null default 0", |
|
353 |
- "encoding not null default ''" |
|
335 |
+ "private not null default 0" |
|
354 | 336 |
]; |
355 | 337 |
for my $column (@$project_columns) { |
356 | 338 |
eval { $dbi->execute("alter table project add column $column") }; |
... | ... |
@@ -440,7 +422,6 @@ sub _create_project { |
440 | 422 |
$dbi->model('number')->update({value => $number}, where => {key => 'original_pid'}); |
441 | 423 |
$params->{original_pid} = $number; |
442 | 424 |
} |
443 |
- use Data::Dumper; |
|
444 | 425 |
$dbi->model('project')->insert($params, id => [$user, $project]); |
445 | 426 |
}); |
446 | 427 |
} |
... | ... |
@@ -449,7 +430,7 @@ sub _create_rep { |
449 | 430 |
my ($self, $user, $project, $opts) = @_; |
450 | 431 |
|
451 | 432 |
# Create repository directory |
452 |
- my $git = $self->git; |
|
433 |
+ my $git = $self->app->git; |
|
453 | 434 |
my $rep = $git->rep($user, $project); |
454 | 435 |
mkdir $rep |
455 | 436 |
or croak "Can't create directory $rep: $!"; |
... | ... |
@@ -483,9 +464,9 @@ sub _create_rep { |
483 | 464 |
or croak "Can't move post-update"; |
484 | 465 |
|
485 | 466 |
# Description |
486 |
- my $description = $opts->{description}; |
|
487 |
- $description = '' unless defined $description; |
|
488 | 467 |
{ |
468 |
+ my $description = $opts->{description}; |
|
469 |
+ $description = '' unless defined $description; |
|
489 | 470 |
my $file = "$rep/description"; |
490 | 471 |
open my $fh, '>', $file |
491 | 472 |
or croak "Can't open $file: $!"; |
... | ... |
@@ -512,8 +493,7 @@ sub _create_rep { |
512 | 493 |
my $file = "$temp_work/README.md"; |
513 | 494 |
open my $readme_fh, '>', $file |
514 | 495 |
or croak "Can't create $file: $!"; |
515 |
- print $readme_fh "# $project\n"; |
|
516 |
- print $readme_fh "\n" . encode('UTF-8', $description) . "\n"; |
|
496 |
+ print $readme_fh "$project\n=====\n"; |
|
517 | 497 |
close $readme_fh; |
518 | 498 |
|
519 | 499 |
my @git_add_cmd = $git->cmd_rep( |
... | ... |
@@ -576,7 +556,7 @@ sub _create_user_dir { |
576 | 556 |
my ($self, $user) = @_; |
577 | 557 |
|
578 | 558 |
# Create user directory |
579 |
- my $rep_home = $self->git->rep_home; |
|
559 |
+ my $rep_home = $self->app->git->rep_home; |
|
580 | 560 |
my $user_dir = "$rep_home/$user"; |
581 | 561 |
mkpath $user_dir; |
582 | 562 |
} |
... | ... |
@@ -594,7 +574,7 @@ sub _delete_user_dir { |
594 | 574 |
my ($self, $user) = @_; |
595 | 575 |
|
596 | 576 |
# Delete user directory |
597 |
- my $rep_home = $self->git->rep_home; |
|
577 |
+ my $rep_home = $self->app->git->rep_home; |
|
598 | 578 |
my $user_dir = "$rep_home/$user"; |
599 | 579 |
rmtree $user_dir; |
600 | 580 |
} |
... | ... |
@@ -611,7 +591,7 @@ sub _delete_rep { |
611 | 591 |
my ($self, $user, $project) = @_; |
612 | 592 |
|
613 | 593 |
# Delete repository |
614 |
- my $rep_home = $self->git->rep_home; |
|
594 |
+ my $rep_home = $self->app->git->rep_home; |
|
615 | 595 |
croak "Can't remove repository. repository home is empty" |
616 | 596 |
if !defined $rep_home || $rep_home eq ''; |
617 | 597 |
my $rep = "$rep_home/$user/$project.git"; |
... | ... |
@@ -643,7 +623,7 @@ sub _exists_rep { |
643 | 623 |
my ($self, $user, $project) = @_; |
644 | 624 |
|
645 | 625 |
# Exists repository |
646 |
- my $rep = $self->git->rep($user, $project); |
|
626 |
+ my $rep = $self->app->git->rep($user, $project); |
|
647 | 627 |
|
648 | 628 |
return -e $rep; |
649 | 629 |
} |
... | ... |
@@ -652,7 +632,7 @@ sub _fork_rep { |
652 | 632 |
my ($self, $user, $project, $to_user, $to_project) = @_; |
653 | 633 |
|
654 | 634 |
# Fork repository |
655 |
- my $git = $self->git; |
|
635 |
+ my $git = $self->app->git; |
|
656 | 636 |
my $rep = $git->rep($user, $project); |
657 | 637 |
my $to_rep = $git->rep($to_user, $to_project); |
658 | 638 |
my @cmd = ( |
... | ... |
@@ -694,8 +674,8 @@ sub _rename_rep { |
694 | 674 |
unless defined $user && defined $project && defined $renamed_project; |
695 | 675 |
|
696 | 676 |
# Rename repository |
697 |
- my $rep = $self->git->rep($user, $project); |
|
698 |
- my $renamed_rep = $self->git->rep($user, $renamed_project); |
|
677 |
+ my $rep = $self->app->git->rep($user, $project); |
|
678 |
+ my $renamed_rep = $self->app->git->rep($user, $renamed_project); |
|
699 | 679 |
move($rep, $renamed_rep) |
700 | 680 |
or croak "Can't move $rep to $renamed_rep: $!"; |
701 | 681 |
} |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
my $api = gitprep_api; |
3 | 3 |
|
4 | 4 |
# Git |
5 |
- my $git = $api->git; |
|
5 |
+ my $git = app->git; |
|
6 | 6 |
|
7 | 7 |
# Branches |
8 | 8 |
my $branches = $git->branches($user, $project) || []; |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
<% |
2 | 2 |
# API |
3 |
- my $api = gitprep_api; |
|
3 |
+ my $api = $self->gitprep_api; |
|
4 | 4 |
|
5 | 5 |
# Parameter |
6 | 6 |
my $user = param('user'); |
... | ... |
@@ -23,7 +23,7 @@ |
23 | 23 |
} |
24 | 24 |
|
25 | 25 |
# Git |
26 |
- my $git = $api->git; |
|
26 |
+ my $git = app->git; |
|
27 | 27 |
|
28 | 28 |
# Object type |
29 | 29 |
my $type = $git->object_type($user, $project, "$rev^{}"); |
... | ... |
@@ -39,7 +39,7 @@ |
39 | 39 |
$params->{salt} = $salt; |
40 | 40 |
|
41 | 41 |
# Create user |
42 |
- eval { $api->manager->create_user($id, $params) }; |
|
42 |
+ eval { app->manager->create_user($id, $params) }; |
|
43 | 43 |
if ($@) { |
44 | 44 |
app->log->error($@); |
45 | 45 |
$errors = ['Internal Error']; |
... | ... |
@@ -23,7 +23,7 @@ |
23 | 23 |
|
24 | 24 |
# Delete user |
25 | 25 |
my $count; |
26 |
- eval { $count = $api->manager->delete_user($user) }; |
|
26 |
+ eval { $count = app->manager->delete_user($user) }; |
|
27 | 27 |
if ($@) { |
28 | 28 |
app->log->error("/_admin/users?op=delete: $@"); |
29 | 29 |
$errors = ['Internal Error']; |
... | ... |
@@ -41,7 +41,7 @@ |
41 | 41 |
else { $errors = $vresult->messages } |
42 | 42 |
} |
43 | 43 |
|
44 |
- my $users = $api->manager->users; |
|
44 |
+ my $users = app->manager->users; |
|
45 | 45 |
%> |
46 | 46 |
|
47 | 47 |
% layout 'common', title => 'Admin Users'; |
... | ... |
@@ -33,7 +33,7 @@ |
33 | 33 |
my $vresult = $validator->validate($params, $rule); |
34 | 34 |
|
35 | 35 |
# Git |
36 |
- my $git = $api->git; |
|
36 |
+ my $git = app->git; |
|
37 | 37 |
if ($vresult->is_ok) { |
38 | 38 |
# Not logined |
39 | 39 |
unless ($api->logined) { |
... | ... |
@@ -46,7 +46,7 @@ |
46 | 46 |
my $description = $data->{description}; |
47 | 47 |
my $readme = $data->{readme}; |
48 | 48 |
|
49 |
- my $manager = $api->manager; |
|
49 |
+ my $manager = app->manager; |
|
50 | 50 |
if ($manager->exists_project($user, $project)) { |
51 | 51 |
$errors = ['Repository already exists']; |
52 | 52 |
} |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
# API |
3 | 3 |
my $api = gitprep_api; |
4 | 4 |
|
5 |
- my $admin_user = $api->manager->admin_user; |
|
5 |
+ my $admin_user = app->manager->admin_user; |
|
6 | 6 |
if (defined $admin_user && $admin_user ne '') { |
7 | 7 |
$self->redirect_to('/'); |
8 | 8 |
return; |
... | ... |
@@ -15,7 +15,7 @@ |
15 | 15 |
if ($op eq 'create') { |
16 | 16 |
|
17 | 17 |
# Check existence admin user |
18 |
- my $admin_user = $api->manager->admin_user; |
|
18 |
+ my $admin_user = app->manager->admin_user; |
|
19 | 19 |
if (defined $admin_user) { $errors = ['Admin user already exists.'] } |
20 | 20 |
else { |
21 | 21 |
# Validation |
... | ... |
@@ -1,8 +1,6 @@ |
1 | 1 |
<% |
2 |
- my $api = gitprep_api; |
|
3 |
- |
|
4 | 2 |
# Users |
5 |
- my $manager = $api->manager; |
|
3 |
+ my $manager = app->manager; |
|
6 | 4 |
my $users = $manager->users; |
7 | 5 |
|
8 | 6 |
# Goto Start page |
... | ... |
@@ -12,7 +12,7 @@ |
12 | 12 |
my $logined_user = $api->logined($user); |
13 | 13 |
|
14 | 14 |
if ($reset_password_conf_on) { |
15 |
- my $admin_user = $api->manager->admin_user; |
|
15 |
+ my $admin_user = app->manager->admin_user; |
|
16 | 16 |
$user = $admin_user ? $admin_user->{id} : undef; |
17 | 17 |
} |
18 | 18 |
elsif (!$logined_admin && !$logined_user) { |
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
my $api = gitprep_api; |
4 | 4 |
|
5 | 5 |
# Git |
6 |
- my $git = $api->git; |
|
6 |
+ my $git = $self->app->git; |
|
7 | 7 |
|
8 | 8 |
# Parameters |
9 | 9 |
my $user = param('user'); |
... | ... |
@@ -5,7 +5,7 @@ |
5 | 5 |
my $api = gitprep_api; |
6 | 6 |
|
7 | 7 |
# Git |
8 |
- my $git = $api->git; |
|
8 |
+ my $git = $self->app->git; |
|
9 | 9 |
|
10 | 10 |
# Parameters |
11 | 11 |
my $user = param('user'); |
... | ... |
@@ -9,7 +9,7 @@ |
9 | 9 |
my $op = param('op') || ''; |
10 | 10 |
|
11 | 11 |
# Git |
12 |
- my $git = $api->git; |
|
12 |
+ my $git = $self->app->git; |
|
13 | 13 |
|
14 | 14 |
# Delete |
15 | 15 |
my $errors; |
... | ... |
@@ -52,7 +52,7 @@ |
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
# Default branch |
55 |
- my $base_branch_name = param('base_branch') || $api->manager->default_branch($user, $project); |
|
55 |
+ my $base_branch_name = param('base_branch') || app->manager->default_branch($user, $project); |
|
56 | 56 |
my $base_branch = $git->branch($user, $project, $base_branch_name); |
57 | 57 |
|
58 | 58 |
# No merged branches |
... | ... |
@@ -9,7 +9,7 @@ |
9 | 9 |
$rev = $diff unless defined $rev; |
10 | 10 |
|
11 | 11 |
# Git |
12 |
- my $git = $api->git; |
|
12 |
+ my $git = app->git; |
|
13 | 13 |
|
14 | 14 |
# Commit |
15 | 15 |
my $commit = $git->get_commit($user, $project, $rev); |
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
my $api = gitprep_api; |
4 | 4 |
|
5 | 5 |
# Git |
6 |
- my $git = $api->git; |
|
6 |
+ my $git = $self->app->git; |
|
7 | 7 |
|
8 | 8 |
# Parameters |
9 | 9 |
my $user = param('user'); |
... | ... |
@@ -10,7 +10,7 @@ |
10 | 10 |
my $page = param('page') || 0; |
11 | 11 |
|
12 | 12 |
# Git |
13 |
- my $git = $api->git; |
|
13 |
+ my $git = $self->app->git; |
|
14 | 14 |
|
15 | 15 |
# Commits |
16 | 16 |
my $commits = $git->forward_commits($user, $project, $from_rev, $rev); |
... | ... |
@@ -14,13 +14,13 @@ |
14 | 14 |
} |
15 | 15 |
|
16 | 16 |
# Repository is already exists |
17 |
- if ($api->manager->exists_project($current_user, $project)) { |
|
17 |
+ if (app->manager->exists_project($current_user, $project)) { |
|
18 | 18 |
$self->redirect_to("/$current_user/$project"); |
19 | 19 |
return; |
20 | 20 |
} |
21 | 21 |
# Fork |
22 | 22 |
else { |
23 |
- eval { $api->manager->fork_project($current_user, $user, $project) }; |
|
23 |
+ eval { app->manager->fork_project($current_user, $user, $project) }; |
|
24 | 24 |
if ($@) { |
25 | 25 |
$self->render_exception('Internal Error'); |
26 | 26 |
app->log->error("/$user/$project/fork: $@"); |
... | ... |
@@ -15,7 +15,7 @@ |
15 | 15 |
} |
16 | 16 |
|
17 | 17 |
# Branches |
18 |
- my $git = $api->git; |
|
18 |
+ my $git = app->git; |
|
19 | 19 |
my $remote_branches = $git->branches($remote_user, $remote_project); |
20 | 20 |
my $remote_branch_names = [map { $_->{name} } @$remote_branches]; |
21 | 21 |
|
... | ... |
@@ -1,10 +1,8 @@ |
1 | 1 |
<% |
2 |
- my $api = gitprep_api; |
|
3 |
- |
|
4 | 2 |
my $rev = stash('rev'); |
5 | 3 |
my $from_rev = stash('from_rev'); |
6 | 4 |
|
7 |
- my $git = $api->git; |
|
5 |
+ my $git = app->git; |
|
8 | 6 |
|
9 | 7 |
my $diff_tree = stash('diff_tree'); |
10 | 8 |
my $blob_diff = stash('blob_diff'); |
... | ... |
@@ -1,13 +1,11 @@ |
1 | 1 |
<% |
2 |
- my $api = gitprep_api; |
|
3 |
- |
|
4 | 2 |
my $display = stash('display') || ''; |
5 | 3 |
my $rev = stash('rev'); |
6 | 4 |
$rev = '' unless defined $rev; |
7 | 5 |
my $branches = stash('branches'); |
8 |
- my $branches_count = $api->git->branches_count($user, $project); |
|
9 |
- my $default_branch_name = $api->manager->default_branch($user, $project); |
|
10 |
- my $tags_count = $api->git->tags_count($user, $project); |
|
6 |
+ my $branches_count = app->git->branches_count($user, $project); |
|
7 |
+ my $default_branch_name = app->manager->default_branch($user, $project); |
|
8 |
+ my $tags_count = app->git->tags_count($user, $project); |
|
11 | 9 |
%> |
12 | 10 |
|
13 | 11 |
%= javascript begin |
... | ... |
@@ -1,12 +1,10 @@ |
1 | 1 |
<% |
2 |
- my $api = gitprep_api; |
|
3 |
- |
|
4 | 2 |
# Parameters |
5 | 3 |
my $rev = stash('rev'); |
6 | 4 |
my $from_rev = stash('from_rev'); |
7 | 5 |
|
8 | 6 |
# Git |
9 |
- my $git = $api->git; |
|
7 |
+ my $git = app->git; |
|
10 | 8 |
|
11 | 9 |
# Diff tree |
12 | 10 |
my $diff_trees = $git->diff_tree( |
... | ... |
@@ -3,8 +3,8 @@ |
3 | 3 |
my $logined = $api->logined; |
4 | 4 |
my $current_user = session('user'); |
5 | 5 |
my $user = stash('user'); |
6 |
- my $original_user = $api->manager->original_user($user, $project); |
|
7 |
- my $original_project = $api->manager->original_project($user, $project); |
|
6 |
+ my $original_user = app->manager->original_user($user, $project); |
|
7 |
+ my $original_project = app->manager->original_project($user, $project); |
|
8 | 8 |
%> |
9 | 9 |
|
10 | 10 |
<div class="row" style="margin-bottom:10px"> |
... | ... |
@@ -2,12 +2,10 @@ |
2 | 2 |
use Mojo::ByteStream (); |
3 | 3 |
use Text::Markdown::Discount (); |
4 | 4 |
|
5 |
- my $api = gitprep_api; |
|
6 |
- |
|
7 | 5 |
# README |
8 | 6 |
my $type; |
9 | 7 |
my $lines; |
10 |
- eval { $lines = $api->git->blob($user, $project, $rev, 'README') }; |
|
8 |
+ eval { $lines = app->git->blob($user, $project, $rev, 'README') }; |
|
11 | 9 |
my $readme_e; |
12 | 10 |
if ($lines) { |
13 | 11 |
$type = 'plain'; |
... | ... |
@@ -16,7 +14,7 @@ |
16 | 14 |
$readme_e =~ s#(^|\s|[^\x00-\x7F])(http(?:s)?://.+?)($|\s|[^\x00-\x7F])#$1<a href="$2">$2</a>$3#msg; |
17 | 15 |
} |
18 | 16 |
else { |
19 |
- eval { $lines = $api->git->blob($user, $project, $rev, 'README.md') }; |
|
17 |
+ eval { $lines = app->git->blob($user, $project, $rev, 'README.md') }; |
|
20 | 18 |
if ($lines) { |
21 | 19 |
$type = 'markdown'; |
22 | 20 |
my $readme = join "\n", @$lines; |
... | ... |
@@ -3,21 +3,21 @@ |
3 | 3 |
my $api = gitprep_api; |
4 | 4 |
|
5 | 5 |
# Branches |
6 |
- my $branches = [map { $_->{name} } @{$api->git->branches($user, $project)}]; |
|
6 |
+ my $branches = [map { $_->{name} } @{app->git->branches($user, $project)}]; |
|
7 | 7 |
|
8 | 8 |
# Members |
9 |
- my $members = $api->manager->members($user, $project); |
|
9 |
+ my $members = app->manager->members($user, $project); |
|
10 | 10 |
|
11 | 11 |
# Members branches |
12 | 12 |
for my $member (@$members) { |
13 | 13 |
my $branches = [ |
14 |
- map { $_->{name} } @{$api->git->branches($member->{id}, $member->{project})} |
|
14 |
+ map { $_->{name} } @{app->git->branches($member->{id}, $member->{project})} |
|
15 | 15 |
]; |
16 | 16 |
$member->{branches} = $branches; |
17 | 17 |
} |
18 | 18 |
|
19 | 19 |
# Default branch |
20 |
- my $default_branch = $api->manager->default_branch($user, $project); |
|
20 |
+ my $default_branch = app->manager->default_branch($user, $project); |
|
21 | 21 |
%> |
22 | 22 |
|
23 | 23 |
% layout 'common', title => "Network \x{30fb} $user/$project"; |
... | ... |
@@ -1,14 +1,12 @@ |
1 | 1 |
<% |
2 |
- my $api = gitprep_api; |
|
3 |
- |
|
4 | 2 |
my $user = param('user'); |
5 | 3 |
my $project = param('project'); |
6 | 4 |
my $branch = param('rev1'); |
7 | 5 |
my $rev2_abs = param('rev2_abs'); |
8 | 6 |
my ($remote_user, $remote_project, $remote_branch) = split /\//, $rev2_abs, 3; |
9 | 7 |
|
10 |
- my $commits = $api->git->get_commits($user, $project, $branch, 100); |
|
11 |
- my $remote_commits = $api->git->get_commits( |
|
8 |
+ my $commits = app->git->get_commits($user, $project, $branch, 100); |
|
9 |
+ my $remote_commits = app->git->get_commits( |
|
12 | 10 |
$remote_user, |
13 | 11 |
$remote_project, |
14 | 12 |
$remote_branch, |
... | ... |
@@ -7,14 +7,14 @@ |
7 | 7 |
my $api = gitprep_api; |
8 | 8 |
|
9 | 9 |
# Git |
10 |
- my $git = $api->git; |
|
10 |
+ my $git = app->git; |
|
11 | 11 |
|
12 | 12 |
# Parameters |
13 | 13 |
my $user = param('user'); |
14 | 14 |
my $project = param('project'); |
15 |
- my $rev = $api->manager->default_branch($user, $project); |
|
15 |
+ my $rev = app->manager->default_branch($user, $project); |
|
16 | 16 |
|
17 |
- unless ($api->manager->exists_project($user, $project)) { |
|
17 |
+ unless (app->manager->exists_project($user, $project)) { |
|
18 | 18 |
$self->render_not_found; |
19 | 19 |
return; |
20 | 20 |
} |
... | ... |
@@ -49,7 +49,7 @@ |
49 | 49 |
my $url = url_for->to_abs; |
50 | 50 |
$url->base(undef); |
51 | 51 |
my $ssh_port = config->{basic}{ssh_port}; |
52 |
- my $rep_home = $api->git->rep_home; |
|
52 |
+ my $rep_home = app->git->rep_home; |
|
53 | 53 |
my $execute_user = getpwuid($>); |
54 | 54 |
my $ssh_rep_url = "ssh://$execute_user\@" . $url->host |
55 | 55 |
. ($ssh_port ? ":$ssh_port" : '') . "$rep_home/$user/$project.git"; |
... | ... |
@@ -1,9 +1,6 @@ |
1 | 1 |
<% |
2 |
- # API |
|
3 |
- my $api = gitprep_api; |
|
4 |
- |
|
5 | 2 |
# Git |
6 |
- my $git = $api->git; |
|
3 |
+ my $git = app->git; |
|
7 | 4 |
|
8 | 5 |
# Parameters |
9 | 6 |
my $user = param('user'); |
... | ... |
@@ -1,9 +1,7 @@ |
1 | 1 |
<% |
2 |
- use Encode (); |
|
3 |
- |
|
4 | 2 |
# API |
5 | 3 |
my $api = gitprep_api; |
6 |
- my $manager = $api->manager; |
|
4 |
+ my $manager = app->manager; |
|
7 | 5 |
|
8 | 6 |
# Parameters |
9 | 7 |
my $op = param('op') || ''; |
... | ... |
@@ -16,7 +14,7 @@ |
16 | 14 |
} |
17 | 15 |
|
18 | 16 |
# Rename project |
19 |
- my $git = $api->git; |
|
17 |
+ my $git = app->git; |
|
20 | 18 |
my $errors; |
21 | 19 |
my $post = lc $self->req->method eq 'post'; |
22 | 20 |
if ($op eq 'rename-project' && $post) { |
... | ... |
@@ -37,11 +35,11 @@ |
37 | 35 |
my $to_project = $data->{'to-project'}; |
38 | 36 |
|
39 | 37 |
# Rename |
40 |
- if ($api->manager->exists_project($user, $to_project)) { |
|
38 |
+ if (app->manager->exists_project($user, $to_project)) { |
|
41 | 39 |
$errors = ["$to_project is already exists"]; |
42 | 40 |
} |
43 | 41 |
else { |
44 |
- eval { $api->manager->rename_project($user, $project, $to_project) }; |
|
42 |
+ eval { app->manager->rename_project($user, $project, $to_project) }; |
|
45 | 43 |
if (my $e = $@) { |
46 | 44 |
app->log->error($e); |
47 | 45 |
$errors = ['Internal Error']; |
... | ... |
@@ -76,7 +74,7 @@ |
76 | 74 |
# Change default branch |
77 | 75 |
elsif ($op eq 'default-branch' && $post) { |
78 | 76 |
my $default_branch = param('default-branch'); |
79 |
- eval { $api->manager->default_branch($user, $project, $default_branch) }; |
|
77 |
+ eval { app->manager->default_branch($user, $project, $default_branch) }; |
|
80 | 78 |
if (my $e = $@) { |
81 | 79 |
app->log->error("/$user/$project/settings?op=default-branch: $e"); |
82 | 80 |
$errors = ['Internal Error']; |
... | ... |
@@ -87,35 +85,7 @@ |
87 | 85 |
return; |
88 | 86 |
} |
89 | 87 |
} |
90 |
- # Encoding |
|
91 |
- elsif ($op eq 'encoding' && $post) { |
|
92 |
- my $encoding = param('encoding') || ''; |
|
93 |
- |
|
94 |
- my $enc = $encoding ? $encoding : 'UTF-8'; |
|
95 |
- my $enc_object = Encode::find_encoding($enc); |
|
96 |
- if ($enc_object) { |
|
97 |
- eval { |
|
98 |
- app->dbi->model('project')->update( |
|
99 |
- {encoding => $encoding}, |
|
100 |
- id => [$user, $project] |
|
101 |
- ); |
|
102 |
- }; |
|
103 |
- if (my $e = $@) { |
|
104 |
- app->log->error("/$user/$project/settings?op=encoding: $e"); |
|
105 |
- $errors = ['Internal Error']; |
|
106 |
- } |
|
107 |
- else { |
|
108 |
- my $message = 'Encoding is saved. Encoding is ' |
|
109 |
- . ($encoding ? $encoding : 'UTF-8(default)'); |
|
110 |
- flash(message => $message); |
|
111 |
- $self->redirect_to('current'); |
|
112 |
- return; |
|
113 |
- } |
|
114 |
- } |
|
115 |
- else { |
|
116 |
- $errors = ["$encoding is invalid encoding"]; |
|
117 |
- } |
|
118 |
- } |
|
88 |
+ |
|
119 | 89 |
# Private repository |
120 | 90 |
elsif ($op eq 'private' && $post) { |
121 | 91 |
my $private = param('private') ? 1 : 0; |
... | ... |
@@ -145,7 +115,7 @@ |
145 | 115 |
my $user = param('user'); |
146 | 116 |
my $project = param('project'); |
147 | 117 |
|
148 |
- eval { $api->manager->delete_project($user, $project) }; |
|
118 |
+ eval { app->manager->delete_project($user, $project) }; |
|
149 | 119 |
if (my $e = $@) { |
150 | 120 |
app->log->error("/$user/$project/settings: $e"); |
151 | 121 |
$errors = ['Internal Error']; |
... | ... |
@@ -156,8 +126,6 @@ |
156 | 126 |
return; |
157 | 127 |
} |
158 | 128 |
} |
159 |
- |
|
160 |
- my $project_info = app->dbi->model('project')->select(id => [$user, $project])->one; |
|
161 | 129 |
%> |
162 | 130 |
|
163 | 131 |
% layout 'common', title => 'Options'; |
... | ... |
@@ -241,31 +209,21 @@ |
241 | 209 |
</div> |
242 | 210 |
</form> |
243 | 211 |
</div> |
244 |
- <div class="border-gray" style="padding:5px 10px;border-top:none;"> |
|
212 |
+ <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;"> |
|
245 | 213 |
<form id="form-default-branch" action="<%= url_for->query(op => 'default-branch') %>" method="post" style="margin-bottom:0px"> |
246 | 214 |
Default Branch |
247 | 215 |
% my $branches = $git->branches($user, $project); |
248 | 216 |
% my $branch_names = [map { $_->{name} } @$branches]; |
249 |
- % my $default_branch = $project_info->{default_branch}; |
|
217 |
+ % my $default_branch = app->manager->default_branch($user, $project); |
|
250 | 218 |
% push @$branch_names, $default_branch unless @$branch_names; |
251 | 219 |
% param('default-branch', $default_branch); |
252 | 220 |
%= select_field 'default-branch' => $branch_names, style => 'margin-top:5px'; |
253 | 221 |
</form> |
254 | 222 |
</div> |
255 |
- <div class="border-gray" style="padding:5px 10px;border-top:none;"> |
|
256 |
- <form action="<%= url_for->query(op => 'encoding') %>" method="post" style="margin-bottom:0px"> |
|
257 |
- Encoding |
|
258 |
- % my $encoding = $project_info->{encoding}; |
|
259 |
- % param('encoding', $encoding); |
|
260 |
- %= text_field 'encoding', style => 'margin-top:5px;width:100px'; |
|
261 |
- <input type="submit" class="btn" value="Save"> |
|
262 |
- (Default is UTF-8) |
|
263 |
- </form> |
|
264 |
- </div> |
|
265 | 223 |
<div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;"> |
266 |
- <form action="<%= url_for->query(op => 'private') %>" method="post" style="margin-bottom:0px"> |
|
224 |
+ <form id="form-default-branch" action="<%= url_for->query(op => 'private') %>" method="post" style="margin-bottom:0px"> |
|
267 | 225 |
<span>Make this repository private</span> |
268 |
- % my $private = $api->manager->is_private_project($user, $project); |
|
226 |
+ % my $private = app->manager->is_private_project($user, $project); |
|
269 | 227 |
% if ($private) { |
270 | 228 |
% param('private', 1); |
271 | 229 |
% } |
... | ... |
@@ -308,7 +266,7 @@ |
308 | 266 |
|
309 | 267 |
<div id="rename-confirm" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="rename-confirm-label" aria-hidden="true"> |
310 | 268 |
<div class="modal-header"> |
311 |
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">??</button> |
|
269 |
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
|
312 | 270 |
<div style="font-weight:bold">Are you sure you want to rename?</div> |
313 | 271 |
</div> |
314 | 272 |
<div class="modal-body"> |
... | ... |
@@ -333,7 +291,7 @@ |
333 | 291 |
|
334 | 292 |
<div id="delete-confirm" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="delete-confirm-label" aria-hidden="true"> |
335 | 293 |
<div class="modal-header"> |
336 |
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">??</button> |
|
294 |
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
|
337 | 295 |
<div style="font-weight:bold">Are you ABSOLUTELY sure?</div> |
338 | 296 |
</div> |
339 | 297 |
<div class="modal-body"> |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
<% |
2 | 2 |
# API |
3 | 3 |
my $api = gitprep_api; |
4 |
- my $manager = $api->manager; |
|
4 |
+ my $manager = app->manager; |
|
5 | 5 |
|
6 | 6 |
# Parameters |
7 | 7 |
my $op = param('op') || ''; |
... | ... |
@@ -15,7 +15,7 @@ |
15 | 15 |
} |
16 | 16 |
|
17 | 17 |
# Rename project |
18 |
- my $git = $api->git; |
|
18 |
+ my $git = app->git; |
|
19 | 19 |
my $errors; |
20 | 20 |
if (lc $self->req->method eq 'post') { |
21 | 21 |
if ($op eq 'add') { |
... | ... |
@@ -3,12 +3,10 @@ |
3 | 3 |
use Symbol (); |
4 | 4 |
use IO::Select (); |
5 | 5 |
|
6 |
- my $api = gitprep_api; |
|
7 |
- |
|
8 | 6 |
my $service = param('service') || ''; |
9 | 7 |
my $user = param('user'); |
10 | 8 |
my $project = param('project'); |
11 |
- my $git = $api->git; |
|
9 |
+ my $git = app->git; |
|
12 | 10 |
|
13 | 11 |
# Smart HTTP |
14 | 12 |
if ($service eq 'git-upload-pack' || $service eq 'git-receive-pack') { |
... | ... |
@@ -67,7 +65,7 @@ |
67 | 65 |
or die "Can't close pipe for @cmd:$!"; |
68 | 66 |
|
69 | 67 |
my $content_type = 'text/plain; charset=UTF-8'; |
70 |
- my $rep_home = $api->git->rep_home; |
|
68 |
+ my $rep_home = app->git->rep_home; |
|
71 | 69 |
my $file = "$rep_home/$user/$project.git/info/refs"; |
72 | 70 |
if (-f $file) { |
73 | 71 |
my $asset = Mojo::Asset::File->new(path => $file); |
... | ... |
@@ -3,13 +3,11 @@ |
3 | 3 |
use Symbol (); |
4 | 4 |
use IO::Select (); |
5 | 5 |
|
6 |
- my $api = gitprep_api; |
|
7 |
- |
|
8 | 6 |
my $service = param('service'); |
9 | 7 |
my $user = param('user'); |
10 | 8 |
my $project = param('project'); |
11 | 9 |
|
12 |
- my $git = $api->git; |
|
10 |
+ my $git = app->git; |
|
13 | 11 |
|
14 | 12 |
my $rep_dir = $git->rep($user, $project); |
15 | 13 |
my @cmd = $git->cmd($user, $project, $service, '--stateless-rpc', $rep_dir); |
... | ... |
@@ -1,6 +1,4 @@ |
1 | 1 |
<% |
2 |
- my $api = gitprep_api; |
|
3 |
- |
|
4 | 2 |
my $path = param('Path'); |
5 | 3 |
my $user = param('user'); |
6 | 4 |
my $project = param('project'); |
... | ... |
@@ -33,7 +31,7 @@ |
33 | 31 |
$content_type = 'application/x-git-packed-objects-toc'; |
34 | 32 |
} |
35 | 33 |
|
36 |
- my $rep_home = $api->git->rep_home; |
|
34 |
+ my $rep_home = app->git->rep_home; |
|
37 | 35 |
my $file = "$rep_home/$user/$project.git/$path"; |
38 | 36 |
if (-f $file) { |
39 | 37 |
my $asset = Mojo::Asset::File->new(path => $file); |
... | ... |
@@ -5,7 +5,7 @@ |
5 | 5 |
my $api = gitprep_api; |
6 | 6 |
|
7 | 7 |
# Git |
8 |
- my $git = $api->git; |
|
8 |
+ my $git = $self->app->git; |
|
9 | 9 |
|
10 | 10 |
# Parameters |
11 | 11 |
my $user = param('user'); |
... | ... |
@@ -8,7 +8,7 @@ |
8 | 8 |
my $page = param('page') || 1; |
9 | 9 |
|
10 | 10 |
# Git |
11 |
- my $git = $api->git; |
|
11 |
+ my $git = $self->app->git; |
|
12 | 12 |
|
13 | 13 |
# Ref names |
14 | 14 |
my $limit = app->config->{basic}{tags_limit}; |
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
my $api = gitprep_api; |
4 | 4 |
|
5 | 5 |
# Git |
6 |
- my $git = $api->git; |
|
6 |
+ my $git = app->git; |
|
7 | 7 |
|
8 | 8 |
# Parameters |
9 | 9 |
my $user = param('user'); |
... | ... |
@@ -1,6 +1,4 @@ |
1 | 1 |
<% |
2 |
- my $api = gitprep_api; |
|
3 |
- |
|
4 | 2 |
# Redirect for project delete |
5 | 3 |
if (my $deleted_project = param('deleted_project')) { |
6 | 4 |
flash('deleted_project', $deleted_project); |
... | ... |
@@ -11,14 +9,14 @@ |
11 | 9 |
my $user = param('user'); |
12 | 10 |
|
13 | 11 |
# Projects |
14 |
- unless ($api->manager->exists_user($user)) { |
|
12 |
+ unless (app->manager->exists_user($user)) { |
|
15 | 13 |
$self->render_not_found; |
16 | 14 |
return; |
17 | 15 |
} |
18 |
- my $projects = $api->manager->projects($user); |
|
16 |
+ my $projects = app->manager->projects($user); |
|
19 | 17 |
my $reps = []; |
20 | 18 |
for my $project (@$projects) { |
21 |
- my $rep = $api->git->repository($user, $project->{name}) || {none => 1}; |
|
19 |
+ my $rep = app->git->repository($user, $project->{name}) || {none => 1}; |
|
22 | 20 |
$rep->{name} = $project->{name}; |
23 | 21 |
push @$reps, $rep; |
24 | 22 |
} |
... | ... |
@@ -1,36 +0,0 @@ |
1 |
-use Test::More 'no_plan'; |
|
2 |
- |
|
3 |
-use FindBin; |
|
4 |
-use utf8; |
|
5 |
-use lib "$FindBin::Bin/../mojo/lib"; |
|
6 |
-use lib "$FindBin::Bin/../lib"; |
|
7 |
-use lib "$FindBin::Bin/../extlib/lib/perl5"; |
|
8 |
-use Encode qw/encode decode/; |
|
9 |
- |
|
10 |
-use Test::Mojo; |
|
11 |
- |
|
12 |
-# Test DB |
|
13 |
-$ENV{GITPREP_DB_FILE} = "$FindBin::Bin/basic_enc.db"; |
|
14 |
- |
|
15 |
-# Test Repository home |
|
16 |
-$ENV{GITPREP_REP_HOME} = "$FindBin::Bin/../../gitprep_t_rep_home"; |
|
17 |
- |
|
18 |
-$ENV{GITPREP_NO_MYCONFIG} = 1; |
|
19 |
- |
|
20 |
-use Gitprep; |
|
21 |
- |
|
22 |
-my $app = Gitprep->new; |
|
23 |
-my $t = Test::Mojo->new($app); |
|
24 |
- |
|
25 |
-my $user = 'kimoto'; |
|
26 |
-my $project = 'gitprep_t'; |
|
27 |
- |
|
28 |
-# For perl 5.8 |
|
29 |
-{ |
|
30 |
- no warnings 'redefine'; |
|
31 |
- sub note { print STDERR "# $_[0]\n" unless $ENV{HARNESS_ACTIVE} } |
|
32 |
-} |
|
33 |
- |
|
34 |
-# Encoding(EUC-jp) |
|
35 |
-$t->get_ok("/$user/$project/blob/ed7b91659762fa612563f0595f3faca6aecfcfa0/euc-jp.txt"); |
|
36 |
-$t->content_like(qr/あああ/); |
... | ... |
@@ -20,6 +20,7 @@ my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/user"; |
20 | 20 |
|
21 | 21 |
$ENV{GITPREP_NO_MYCONFIG} = 1; |
22 | 22 |
|
23 |
+ |
|
23 | 24 |
use Gitprep; |
24 | 25 |
|
25 | 26 |
# For perl 5.8 |
... | ... |
@@ -606,37 +607,3 @@ note 'Private repository and collaborator'; |
606 | 607 |
$t->get_ok("/kimoto/t1"); |
607 | 608 |
$t->content_like(qr/t1 is private repository/); |
608 | 609 |
} |
609 |
- |
|
610 |
-note 'Project encoding'; |
|
611 |
-{ |
|
612 |
- unlink $db_file; |
|
613 |
- rmtree $rep_home; |
|
614 |
- |
|
615 |
- my $app = Gitprep->new; |
|
616 |
- my $t = Test::Mojo->new($app); |
|
617 |
- $t->ua->max_redirects(3); |
|
618 |
- |
|
619 |
- # Create admin user |
|
620 |
- $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
|
621 |
- $t->content_like(qr/Login page/); |
|
622 |
- |
|
623 |
- # Login success |
|
624 |
- $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'}); |
|
625 |
- $t->content_like(qr/Admin/); |
|
626 |
- |
|
627 |
- # Create user |
|
628 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'}); |
|
629 |
- $t->content_like(qr/Success.*created/); |
|
630 |
- |
|
631 |
- # Login as kimoto |
|
632 |
- $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'}); |
|
633 |
- $t->get_ok('/')->content_like(qr/kimoto/); |
|
634 |
- |
|
635 |
- # Create repository |
|
636 |
- $t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello', readme => 1}); |
|
637 |
- $t->content_like(qr/README/); |
|
638 |
- |
|
639 |
- # Change encoding |
|
640 |
- $t->post_ok("/kimoto/t1/settings?op=encoding", form => {encoding => 'EUC-jp'}); |
|
641 |
- $t->content_like(qr/Encoding is EUC-jp/); |
|
642 |
-} |