line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Demo::Story::Character; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
5
|
use Git::Demo::Story::Event; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
1237
|
use File::Util; |
|
1
|
|
|
|
|
22581
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
1000
|
use File::Spec::Functions; |
|
1
|
|
|
|
|
832
|
|
|
1
|
|
|
|
|
466
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new{ |
9
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
10
|
0
|
|
|
|
|
|
my $args = shift; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my $self = {}; |
13
|
0
|
|
|
|
|
|
foreach( qw/name story/ ){ |
14
|
0
|
0
|
|
|
|
|
if( ! $args->{$_} ){ |
15
|
0
|
|
|
|
|
|
die( "Required agr $_ not defined" ); |
16
|
|
|
|
|
|
|
} |
17
|
0
|
|
|
|
|
|
$self->{$_} = $args->{$_}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $logger = Log::Log4perl->get_logger( __PACKAGE__ ); |
21
|
0
|
|
|
|
|
|
$self->{logger} = $logger; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
0
|
|
0
|
|
|
|
$self->{dir} = $args->{dir} || catfile( $args->{story}->dir(), $args->{name} ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
##FIXME |
27
|
|
|
|
|
|
|
# Add all git variables which could be useful |
28
|
|
|
|
|
|
|
# Replace zipmail domain with something configurable! |
29
|
0
|
|
|
|
|
|
my $options = { |
30
|
|
|
|
|
|
|
env => { |
31
|
|
|
|
|
|
|
GIT_COMMITTER_EMAIL => $args->{name} . '@zipmail.com', |
32
|
|
|
|
|
|
|
GIT_COMMITTER_NAME => $args->{name}, |
33
|
|
|
|
|
|
|
GIT_AUTHOR_EMAIL => $args->{name} . '@zipmail.com', |
34
|
|
|
|
|
|
|
GIT_AUTHOR_NAME => $args->{name}, |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if( ! -d $self->{dir} ){ |
39
|
0
|
|
|
|
|
|
my $f = File::Util->new(); |
40
|
0
|
|
|
|
|
|
$logger->debug( "Creating repository directory for character: $args->{name}" ); |
41
|
0
|
0
|
|
|
|
|
if( ! $f->make_dir( $self->{dir} ) ){ |
42
|
0
|
|
|
|
|
|
die( "Could not create user dir $self->{dir}\n$!\n" ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
##FIXME |
47
|
|
|
|
|
|
|
# There should be options to use existing, or even remote (ssh?) repositories |
48
|
|
|
|
|
|
|
# For now default is always initialise |
49
|
|
|
|
|
|
|
##FIXME |
50
|
|
|
|
|
|
|
# This should be moved to the Actions/Git section |
51
|
0
|
|
|
|
|
|
$logger->debug( "Initialising repository character: $args->{name}" ); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my @git_args = ( 'init' ); |
54
|
0
|
0
|
|
|
|
|
if( $args->{git_args} ){ |
55
|
0
|
|
|
|
|
|
push( @git_args, @{ $args->{git_args} } ); |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
push( @git_args, $self->{dir} ); |
58
|
0
|
|
|
|
|
|
push( @git_args, $options ); |
59
|
0
|
|
|
|
|
|
$self->{git} = Git::Repository->create( @git_args ); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
bless $self, $class; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub dir{ |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
return $self->{dir}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub git{ |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
return $self->{git}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub name{ |
77
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
return $self->{name}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
1; |