line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Rgit::Config; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
24496
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
170
|
|
4
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
121
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
24
|
use Carp (); # confess |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
66
|
|
7
|
5
|
|
|
5
|
|
22
|
use Cwd (); # cwd |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
115
|
|
8
|
5
|
|
|
5
|
|
23
|
use File::Spec (); # canonpath, catfile, path |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
114
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
2734
|
use App::Rgit::Repository; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
166
|
|
11
|
5
|
|
|
5
|
|
33
|
use App::Rgit::Utils qw/:levels/; # :levels, abs_path |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
789
|
|
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
25
|
use constant IS_WIN32 => $^O eq 'MSWin32'; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
3520
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
App::Rgit::Config - Base class for App::Rgit configurations. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Version 0.08 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Base class for L configurations. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This is an internal class to L. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 C<< new root => $root, git => $git >> |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Creates a new configuration object based on the root directory C<$root> and using C<$git> as F executable. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
23
|
|
|
23
|
1
|
5258
|
my $class = shift; |
43
|
23
|
|
33
|
|
|
392
|
$class = ref $class || $class; |
44
|
|
|
|
|
|
|
|
45
|
23
|
|
|
|
|
163
|
my %args = @_; |
46
|
|
|
|
|
|
|
|
47
|
23
|
100
|
|
|
|
5423
|
my $root = defined $args{root} |
|
|
100
|
|
|
|
|
|
48
|
|
|
|
|
|
|
? $args{root} |
49
|
|
|
|
|
|
|
: defined $ENV{GIT_DIR} |
50
|
|
|
|
|
|
|
? $ENV{GIT_DIR} |
51
|
|
|
|
|
|
|
: Cwd::cwd; |
52
|
23
|
100
|
|
|
|
1439
|
Carp::confess("Invalid root directory") unless -d $root; |
53
|
22
|
|
|
|
|
339
|
$root = File::Spec->canonpath(App::Rgit::Utils::abs_path($root)); |
54
|
|
|
|
|
|
|
|
55
|
22
|
|
|
|
|
50
|
my $git; |
56
|
22
|
100
|
|
|
|
221
|
my @candidates = ( |
|
|
100
|
|
|
|
|
|
57
|
|
|
|
|
|
|
defined $args{git} |
58
|
|
|
|
|
|
|
? $args{git} |
59
|
|
|
|
|
|
|
: defined $ENV{GIT_EXEC_PATH} |
60
|
|
|
|
|
|
|
? $ENV{GIT_EXEC_PATH} |
61
|
|
|
|
|
|
|
: map File::Spec->catfile($_, 'git'), File::Spec->path |
62
|
|
|
|
|
|
|
); |
63
|
22
|
|
|
|
|
48
|
if (IS_WIN32) { |
64
|
|
|
|
|
|
|
my @acc; |
65
|
|
|
|
|
|
|
for my $c (@candidates) { |
66
|
|
|
|
|
|
|
push @acc, $c, map "$c.$_", qw/exe com bat cmd/; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
@candidates = @acc; |
69
|
|
|
|
|
|
|
} |
70
|
22
|
|
|
|
|
111
|
for my $c (@candidates) { |
71
|
22
|
100
|
|
|
|
493
|
if (-x $c) { |
72
|
21
|
|
|
|
|
42
|
$git = $c; |
73
|
21
|
|
|
|
|
86
|
last; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
22
|
100
|
|
|
|
540
|
Carp::confess("Couldn't find a proper git executable") unless defined $git; |
77
|
21
|
|
|
|
|
177
|
$git = File::Spec->canonpath(App::Rgit::Utils::abs_path($git)); |
78
|
|
|
|
|
|
|
|
79
|
21
|
|
|
|
|
50
|
my $conf = 'App::Rgit::Config::Default'; |
80
|
21
|
50
|
|
|
|
2066
|
eval "require $conf; 1" or Carp::confess("Couldn't load $conf: $@"); |
81
|
|
|
|
|
|
|
|
82
|
21
|
|
|
|
|
274
|
my $r = App::Rgit::Repository->new(fake => 1); |
83
|
21
|
50
|
|
|
|
169
|
return unless defined $r; |
84
|
|
|
|
|
|
|
|
85
|
21
|
100
|
|
|
|
1995
|
bless { |
86
|
|
|
|
|
|
|
root => $root, |
87
|
|
|
|
|
|
|
git => $git, |
88
|
|
|
|
|
|
|
cwd_repo => $r, |
89
|
|
|
|
|
|
|
debug => defined $args{debug} ? int $args{debug} : WARN, |
90
|
|
|
|
|
|
|
}, $conf; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 C |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 C |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Notifies a message C<$msg> of the corresponding level. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _notify { |
106
|
44
|
|
|
44
|
|
110
|
my $self = shift; |
107
|
44
|
|
|
|
|
62
|
my $level = shift; |
108
|
44
|
100
|
|
|
|
2866
|
if ($self->debug >= $level) { |
109
|
10
|
|
|
|
|
28
|
print STDERR @_; |
110
|
10
|
|
|
|
|
29
|
return 1; |
111
|
|
|
|
|
|
|
} |
112
|
34
|
|
|
|
|
112
|
return 0; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
32
|
|
|
32
|
1
|
6680
|
sub info { shift->_notify(INFO, @_) } |
116
|
|
|
|
|
|
|
|
117
|
4
|
|
|
4
|
1
|
34
|
sub warn { shift->_notify(WARN, @_) } |
118
|
|
|
|
|
|
|
|
119
|
4
|
|
|
4
|
1
|
48
|
sub err { shift->_notify(ERR, @_) } |
120
|
|
|
|
|
|
|
|
121
|
4
|
|
|
4
|
1
|
29
|
sub crit { shift->_notify(CRIT, @_) } |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 C |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 C |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 C |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 C |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 C |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Read-only accessors. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
BEGIN { |
138
|
5
|
|
|
5
|
1
|
981
|
eval "sub $_ { \$_[0]->{$_} }" for qw/root git cwd_repo debug/; |
|
9
|
|
|
9
|
1
|
216
|
|
|
44
|
|
|
44
|
1
|
240
|
|
|
23
|
|
|
23
|
1
|
144
|
|
|
57
|
|
|
57
|
|
1541
|
|
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SEE ALSO |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 BUGS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
154
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 SUPPORT |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
perldoc App::Rgit::Config |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright 2008,2009,2010 Vincent Pit, all rights reserved. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; # End of App::Rgit::Config |