... | ... |
@@ -21,11 +21,18 @@ use Validator::Custom; |
21 | 21 |
our $VERSION = '1.0301'; |
22 | 22 |
|
23 | 23 |
has 'dbi'; |
24 |
-has 'git'; |
|
25 | 24 |
has 'manager'; |
26 | 25 |
has 'validator'; |
27 | 26 |
|
28 |
-use constant BUFFER_SIZE => 8192; |
|
27 |
+sub git { |
|
28 |
+ my $self = shift; |
|
29 |
+ |
|
30 |
+ my $git = Gitprep::Git->new; |
|
31 |
+ $git->bin($self->config->{internal}{git_bin}); |
|
32 |
+ $git->rep_home($self->config->{internal}{git_rep_home}); |
|
33 |
+ |
|
34 |
+ return $git; |
|
35 |
+} |
|
29 | 36 |
|
30 | 37 |
sub startup { |
31 | 38 |
my $self = shift; |
... | ... |
@@ -45,7 +52,7 @@ sub startup { |
45 | 52 |
$listen = [split /,/, $listen] unless ref $listen eq 'ARRAY'; |
46 | 53 |
$conf->{hypnotoad}{listen} = $listen; |
47 | 54 |
|
48 |
- # Git |
|
55 |
+ # Git settings |
|
49 | 56 |
my $git = Gitprep::Git->new; |
50 | 57 |
my $git_bin |
51 | 58 |
= $conf->{basic}{git_bin} ? $conf->{basic}{git_bin} : $git->search_bin; |
... | ... |
@@ -56,24 +63,20 @@ sub startup { |
56 | 63 |
$self->log->error($error); |
57 | 64 |
croak $error; |
58 | 65 |
} |
59 |
- $git->bin($git_bin); |
|
60 |
- |
|
61 |
- # Repository Manager |
|
62 |
- my $manager = Gitprep::Manager->new(app => $self); |
|
63 |
- weaken $manager->{app}; |
|
64 |
- $self->manager($manager); |
|
65 |
- |
|
66 |
+ $conf->{internal}{git_bin} = $git_bin; |
|
67 |
+ |
|
66 | 68 |
# Repository home |
67 | 69 |
my $rep_home = $ENV{GITPREP_REP_HOME} || $self->home->rel_file('data/rep'); |
68 |
- $git->rep_home($rep_home); |
|
69 | 70 |
unless (-d $rep_home) { |
70 | 71 |
mkdir $rep_home |
71 | 72 |
or croak "Can't create directory $rep_home: $!"; |
72 | 73 |
} |
73 |
- $self->git($git); |
|
74 |
+ $conf->{internal}{git_rep_home} = $rep_home; |
|
74 | 75 |
|
75 |
- # Added public path |
|
76 |
- # push @{$self->static->paths}, $rep_home; |
|
76 |
+ # Repository Manager |
|
77 |
+ my $manager = Gitprep::Manager->new(app => $self); |
|
78 |
+ weaken $manager->{app}; |
|
79 |
+ $self->manager($manager); |
|
77 | 80 |
|
78 | 81 |
# DBI |
79 | 82 |
my $db_file = $ENV{GITPREP_DB_FILE} |
... | ... |
@@ -58,6 +58,7 @@ sub can_access_private_project { |
58 | 58 |
my ($self, $user, $project) = @_; |
59 | 59 |
|
60 | 60 |
my $session_user = $self->cntl->session('user'); |
61 |
+ return unless $session_user; |
|
61 | 62 |
|
62 | 63 |
my $is_valid = |
63 | 64 |
($user eq $session_user || $self->is_collaborator($user, $project)) |