line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RepRoot; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
27838
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
1229
|
use FindBin qw( $RealBin ); |
|
1
|
|
|
|
|
1346
|
|
|
1
|
|
|
|
|
141
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
34
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
255
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# figure out full absolute path of executable and split into components |
14
|
1
|
|
|
1
|
|
16
|
my ( $volume, $directories, $file ) = File::Spec->splitpath( $RealBin, 1 ); |
15
|
1
|
|
|
|
|
18
|
my @directories = File::Spec->splitdir( $directories ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# keep searching up the path till you hit root or find the .reproot file |
18
|
1
|
|
|
|
|
7
|
while ( @directories ) { |
19
|
|
|
|
|
|
|
# assemble next possible .reproot path |
20
|
5
|
|
|
|
|
67
|
my $reproot_file = File::Spec->catpath( $volume, File::Spec->catdir( @directories ), '.reproot' ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# check for existence of .reproot file |
23
|
5
|
50
|
|
|
|
77
|
if ( -e $reproot_file ) { |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# we found the root! |
26
|
0
|
|
|
|
|
0
|
$RepRoot::ROOT = File::Spec->catpath( $volume, File::Spec->catdir( @directories ) ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# if the file has a non-zero size, execute it |
29
|
0
|
0
|
|
|
|
0
|
if ( -s $reproot_file ) { |
30
|
0
|
0
|
|
|
|
0
|
unless ( my $return = do $reproot_file ) { |
31
|
0
|
0
|
|
|
|
0
|
die "couldn't parse $reproot_file: $@" if $@; |
32
|
0
|
0
|
|
|
|
0
|
die "couldn't do $reproot_file: $!" unless defined $return; |
33
|
0
|
0
|
|
|
|
0
|
die "couldn't run $reproot_file" unless $return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# we're done! |
38
|
0
|
|
|
|
|
0
|
last; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# didn't find it; move up a level and try again |
42
|
5
|
|
|
|
|
14
|
pop( @directories ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# throw exception if no .reproot file found |
46
|
1
|
50
|
|
|
|
48
|
die "couldn't find repository root (indicated by existence of '.reproot' file)" unless defined $RepRoot::ROOT; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |