Showing 6 changed files with 8 additions and 21 deletions
+2 -3
lib/Gitprep.pm
... ...
@@ -84,9 +84,8 @@ sub startup {
84 84
   $conf->{hypnotoad}{listen} = $listen;
85 85
   
86 86
   # Data directory
87
-  unless ($self->config('data_dir')) {
88
-    $self->config('data_dir' => $self->home->rel_file('data'));
89
-  }
87
+  my $data_dir = $ENV{GITPREP_DATA_DIR} ? $ENV{GITPREP_DATA_DIR} : $self->home->rel_file('data');
88
+  $self->config(data_dir => $data_dir);
90 89
   
91 90
   # Git
92 91
   my $git = Gitprep::Git->new;
+2 -1
script/import_rep
... ...
@@ -10,9 +10,10 @@ use Getopt::Long;
10 10
 use File::Basename 'basename';
11 11
 use Gitprep;
12 12
 use Encode 'decode';
13
+use Mojo::Server;
13 14
 
14 15
 no warnings;
15
-my $app = Gitprep->new;
16
+my $app = Mojo::Server->new->load_app("$FindBin::Bin/gitprep");
16 17
 my $dbi = $app->dbi;
17 18
 my $manager = $app->manager;
18 19
 my $git = $app->git;
+1 -2
xt/basic.t
... ...
@@ -9,7 +9,7 @@ use Encode qw/encode decode/;
9 9
 use Test::Mojo;
10 10
 
11 11
 # Data directory
12
-my $data_dir = "$FindBin::Bin/basic";
12
+my $data_dir =  $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/basic";
13 13
 
14 14
 # Test DB
15 15
 $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/basic/gitprep.db";
... ...
@@ -25,7 +25,6 @@ $ENV{GITPREP_NO_MYCONFIG} = 1;
25 25
 use Gitprep;
26 26
 
27 27
 my $app = Gitprep->new;
28
-$app->config(data_dir => $data_dir);
29 28
 $app->manager->setup_database;
30 29
 
31 30
 my $t = Test::Mojo->new($app);
+1 -2
xt/import_rep.t
... ...
@@ -12,7 +12,7 @@ use Encode qw/encode decode/;
12 12
 use Test::Mojo;
13 13
 
14 14
 # Data directory
15
-my $data_dir = "$FindBin::Bin/import_rep";
15
+my $data_dir =  $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/import_rep";
16 16
 
17 17
 # Test DB
18 18
 my $db_file = $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/import_rep/gitprep.db";
... ...
@@ -30,7 +30,6 @@ note 'import_rep';
30 30
   rmtree $rep_home;
31 31
 
32 32
   my $app = Gitprep->new;
33
-  $app->config(data_dir => $data_dir);
34 33
   $app->manager->setup_database;
35 34
 
36 35
   my $t = Test::Mojo->new($app);
+1 -3
xt/smart_http.t
... ...
@@ -13,7 +13,7 @@ use MIME::Base64 'encode_base64';
13 13
 use Test::Mojo;
14 14
 
15 15
 # Data directory
16
-my $data_dir = "$FindBin::Bin/smart_http";
16
+my $data_dir =  $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/smart_http";
17 17
 
18 18
 # Test DB
19 19
 my $db_file = $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/smart_http/gitprep.db";
... ...
@@ -31,7 +31,6 @@ note 'Smart HTTP';
31 31
   rmtree $rep_home;
32 32
 
33 33
   my $app = Gitprep->new;
34
-  $app->config(data_dir => $data_dir);
35 34
   $app->manager->setup_database;
36 35
 
37 36
   my $t = Test::Mojo->new($app);
... ...
@@ -142,7 +141,6 @@ note 'Private repository and collaborator';
142 141
   rmtree $rep_home;
143 142
 
144 143
   my $app = Gitprep->new;
145
-  $app->config(data_dir => $data_dir);
146 144
   $app->manager->setup_database;
147 145
 
148 146
   my $t = Test::Mojo->new($app);
+1 -10
xt/user.t
... ...
@@ -12,7 +12,7 @@ use Encode qw/encode decode/;
12 12
 use Test::Mojo;
13 13
 
14 14
 # Data directory
15
-my $data_dir = "$FindBin::Bin/user";
15
+my $data_dir =  $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/user";
16 16
 
17 17
 # Test DB
18 18
 my $db_file = $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/user/gitprep.db";
... ...
@@ -29,7 +29,6 @@ note 'Start page';
29 29
   unlink $db_file;
30 30
 
31 31
   my $app = Gitprep->new;
32
-  $app->config(data_dir => $data_dir);
33 32
   $app->manager->setup_database;
34 33
   
35 34
   my $t = Test::Mojo->new($app);
... ...
@@ -69,7 +68,6 @@ note 'Admin page';
69 68
   unlink $db_file;
70 69
 
71 70
   my $app = Gitprep->new;
72
-  $app->config(data_dir => $data_dir);
73 71
   $app->manager->setup_database;
74 72
 
75 73
   my $t = Test::Mojo->new($app);
... ...
@@ -211,7 +209,6 @@ note 'Reset password';
211 209
   unlink $db_file;
212 210
 
213 211
   my $app = Gitprep->new;
214
-  $app->config(data_dir => $data_dir);
215 212
   $app->manager->setup_database;
216 213
 
217 214
   my $t = Test::Mojo->new($app);
... ...
@@ -273,7 +270,6 @@ note 'Profile';
273 270
   rmtree $rep_home;
274 271
 
275 272
   my $app = Gitprep->new;
276
-  $app->config(data_dir => $data_dir);
277 273
   $app->manager->setup_database;
278 274
 
279 275
   my $t = Test::Mojo->new($app);
... ...
@@ -416,7 +412,6 @@ note 'Profile';
416 412
 note 'fork';
417 413
 {
418 414
   my $app = Gitprep->new;
419
-  $app->config(data_dir => $data_dir);
420 415
   $app->manager->setup_database;
421 416
 
422 417
   my $t = Test::Mojo->new($app);
... ...
@@ -444,7 +439,6 @@ note 'fork';
444 439
 note 'Network';
445 440
 {
446 441
   my $app = Gitprep->new;
447
-  $app->config(data_dir => $data_dir);
448 442
   $app->manager->setup_database;
449 443
 
450 444
   my $t = Test::Mojo->new($app);
... ...
@@ -466,7 +460,6 @@ note 'Network';
466 460
 note 'Delete branch';
467 461
 {
468 462
   my $app = Gitprep->new;
469
-  $app->config(data_dir => $data_dir);
470 463
   $app->manager->setup_database;
471 464
 
472 465
   my $t = Test::Mojo->new($app);
... ...
@@ -500,7 +493,6 @@ note 'Delete branch';
500 493
 note 'import-branch';
501 494
 {
502 495
   my $app = Gitprep->new;
503
-  $app->config(data_dir => $data_dir);
504 496
   $app->manager->setup_database;
505 497
 
506 498
   my $t = Test::Mojo->new($app);
... ...
@@ -572,7 +564,6 @@ note 'Private repository and collaborator';
572 564
   rmtree $rep_home;
573 565
 
574 566
   my $app = Gitprep->new;
575
-  $app->config(data_dir => $data_dir);
576 567
   $app->manager->setup_database;
577 568
 
578 569
   my $t = Test::Mojo->new($app);