line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::bif::new::repo; |
2
|
51
|
|
|
51
|
|
8785
|
use strict; |
|
51
|
|
|
|
|
74
|
|
|
51
|
|
|
|
|
1544
|
|
3
|
51
|
|
|
51
|
|
218
|
use warnings; |
|
51
|
|
|
|
|
65
|
|
|
51
|
|
|
|
|
1469
|
|
4
|
51
|
|
|
51
|
|
192
|
use Bif::Mo; |
|
51
|
|
|
|
|
67
|
|
|
51
|
|
|
|
|
286
|
|
5
|
51
|
|
|
51
|
|
17836
|
use Bif::DBW; |
|
51
|
|
|
|
|
148
|
|
|
51
|
|
|
|
|
433
|
|
6
|
51
|
|
|
51
|
|
2106
|
use Config::Tiny; |
|
51
|
|
|
|
|
88
|
|
|
51
|
|
|
|
|
1290
|
|
7
|
51
|
|
|
51
|
|
185
|
use Log::Any '$log'; |
|
51
|
|
|
|
|
77
|
|
|
51
|
|
|
|
|
207
|
|
8
|
51
|
|
|
51
|
|
6077
|
use Path::Tiny qw/path tempdir/; |
|
51
|
|
|
|
|
80
|
|
|
51
|
|
|
|
|
24313
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.1.5_5'; |
11
|
|
|
|
|
|
|
extends 'App::bif'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has subref => ( is => 'ro', ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub run { |
16
|
103
|
|
|
103
|
1
|
180
|
my $self = shift; |
17
|
103
|
|
|
|
|
297
|
my $opts = $self->opts; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return $self->err( 'DirExists', 'location exists: ' . $opts->{directory} ) |
20
|
103
|
100
|
|
|
|
972
|
if -e $opts->{directory}; |
21
|
|
|
|
|
|
|
|
22
|
102
|
|
|
|
|
2554
|
$opts->{directory} = path( $opts->{directory} ); |
23
|
102
|
|
|
|
|
2239
|
$opts->{directory}->parent->mkpath; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $tempdir = tempdir( |
26
|
|
|
|
|
|
|
CLEANUP => !$opts->{debug}, |
27
|
|
|
|
|
|
|
DIR => $opts->{directory}->parent, |
28
|
102
|
|
|
|
|
15405
|
TEMPLATE => 'bif-new-repo-XXXXXX', |
29
|
|
|
|
|
|
|
); |
30
|
102
|
|
|
|
|
57233
|
$log->debug( 'init: tmpdir ' . $tempdir ); |
31
|
|
|
|
|
|
|
|
32
|
102
|
|
|
|
|
2916
|
$self->repo($tempdir); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Fake App::bif into thinking the database already exists |
35
|
102
|
|
|
|
|
650
|
$tempdir->child( $self->dbfile( $self->DBVERSION ) )->touch; |
36
|
102
|
|
|
|
|
500792
|
my $dbw = $self->dbw; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# On windows at least, an SQLite handle on the database prevents a |
39
|
|
|
|
|
|
|
# rename or temp directory removal. Unfortunately, doing the |
40
|
|
|
|
|
|
|
# eval/disconnect check below results in the "uncleared implementors |
41
|
|
|
|
|
|
|
# data" warning on error. For the moment I would prefer the warning |
42
|
|
|
|
|
|
|
# than have the user left with a temporary directory to clean up. |
43
|
|
|
|
|
|
|
|
44
|
102
|
|
|
|
|
232
|
eval { |
45
|
|
|
|
|
|
|
$dbw->txn( |
46
|
|
|
|
|
|
|
sub { |
47
|
102
|
|
|
102
|
|
124632
|
$|++; |
48
|
102
|
|
|
|
|
1376
|
printf "Creating repository: %s ", $opts->{directory}; |
49
|
|
|
|
|
|
|
|
50
|
102
|
|
|
|
|
1040160
|
my ( $old, $new ) = $dbw->deploy( $self->DBVERSION ); |
51
|
102
|
|
|
|
|
40928816
|
printf "(v%d.%d)\n", $self->DBVERSION, $new; |
52
|
|
|
|
|
|
|
|
53
|
102
|
100
|
|
|
|
1536
|
$self->subref->( $self, $self->DBVERSION, $new ) |
54
|
|
|
|
|
|
|
if $self->subref; |
55
|
|
|
|
|
|
|
} |
56
|
102
|
|
|
|
|
1658
|
); |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
102
|
100
|
|
|
|
6471143
|
if ( my $err = $@ ) { |
60
|
49
|
|
|
|
|
4976
|
$dbw->disconnect; |
61
|
49
|
|
|
|
|
7042
|
Carp::croak $err; |
62
|
|
|
|
|
|
|
} |
63
|
53
|
|
|
|
|
108271
|
$dbw->disconnect; |
64
|
|
|
|
|
|
|
|
65
|
53
|
100
|
|
|
|
421
|
if ( $opts->{config} ) { |
66
|
49
|
|
|
|
|
681
|
my $conf = Config::Tiny->new; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$conf->{'user.alias'}->{ls} = |
69
|
49
|
|
|
|
|
666
|
'list topics --status open --project-status run'; |
70
|
|
|
|
|
|
|
$conf->{'user.alias'}->{lss} = |
71
|
49
|
|
|
|
|
149
|
'list topics --status open --status stalled --project-status run'; |
72
|
49
|
|
|
|
|
142
|
$conf->{'user.alias'}->{l} = 'list projects define plan run'; |
73
|
49
|
|
|
|
|
218
|
$conf->{'user.alias'}->{lsi} = 'list identities'; |
74
|
|
|
|
|
|
|
|
75
|
49
|
|
|
|
|
405
|
$conf->write( $tempdir->child('config') ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Mark this as a repo for convenience |
79
|
53
|
|
|
|
|
45463
|
$tempdir->child('.bif')->touch; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$tempdir->move( $opts->{directory} ) |
82
|
53
|
50
|
|
|
|
15727
|
|| return $self->err( 'Rename', |
83
|
|
|
|
|
|
|
"rename $tempdir $opts->{directory}: $!" ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Rebuild the dbw for further commands? |
86
|
53
|
|
|
|
|
4839
|
$self->repo( $opts->{directory} ); |
87
|
53
|
|
|
|
|
588
|
$self->dbw( $self->_build_dbw ); |
88
|
|
|
|
|
|
|
|
89
|
53
|
|
|
|
|
533
|
return $self->ok('NewRepo'); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
__END__ |