line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OTRS::OPM::Maker::Command::filetest; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: check if filelist in .sopm includes the files on your disk |
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
10386
|
use strict; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
506
|
|
6
|
14
|
|
|
14
|
|
84
|
use warnings; |
|
14
|
|
|
|
|
40
|
|
|
14
|
|
|
|
|
436
|
|
7
|
|
|
|
|
|
|
|
8
|
14
|
|
|
14
|
|
6604
|
use File::Find::Rule; |
|
14
|
|
|
|
|
104064
|
|
|
14
|
|
|
|
|
127
|
|
9
|
14
|
|
|
14
|
|
2568
|
use Path::Class (); |
|
14
|
|
|
|
|
134667
|
|
|
14
|
|
|
|
|
356
|
|
10
|
14
|
|
|
14
|
|
3002
|
use XML::LibXML; |
|
14
|
|
|
|
|
207707
|
|
|
14
|
|
|
|
|
88
|
|
11
|
|
|
|
|
|
|
|
12
|
14
|
|
|
14
|
|
3608
|
use OTRS::OPM::Maker -command; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
114
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub abstract { |
17
|
1
|
|
|
1
|
1
|
3430
|
return "Check if filelist in .sopm includes the files on your disk"; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub usage_desc { |
21
|
1
|
|
|
1
|
1
|
984
|
return "opmbuild filetest "; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub validate_args { |
25
|
8
|
|
|
8
|
1
|
8676
|
my ($self, $opt, $args) = @_; |
26
|
|
|
|
|
|
|
|
27
|
8
|
100
|
100
|
|
|
138
|
$self->usage_error( 'need path to .sopm' ) if |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
28
|
|
|
|
|
|
|
!$args or |
29
|
|
|
|
|
|
|
'ARRAY' ne ref $args or |
30
|
|
|
|
|
|
|
!defined $args->[0] or |
31
|
|
|
|
|
|
|
$args->[0] !~ /\.sopm\z/ or |
32
|
|
|
|
|
|
|
!-f $args->[0]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub execute { |
36
|
2
|
|
|
2
|
1
|
2836
|
my ($self, $opt, $args) = @_; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
39
|
my $file = $args->[0]; |
39
|
2
|
|
|
|
|
35
|
my $parser = XML::LibXML->new; |
40
|
2
|
|
|
|
|
60
|
my $tree = $parser->parse_file( $file ); |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
944
|
my $sopm_path = Path::Class::File->new( $file ); |
43
|
2
|
|
|
|
|
456
|
my $path = $sopm_path->dir; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
34
|
my $path_str = $path->stringify; |
46
|
2
|
|
|
|
|
108
|
my $ignore_files = File::Find::Rule->file->name(".*"); |
47
|
2
|
|
|
|
|
420
|
my @files_in_fs = File::Find::Rule->file |
48
|
|
|
|
|
|
|
->not( $ignore_files ) |
49
|
|
|
|
|
|
|
->in ( $path_str ); |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
|
|
56
|
my %fs = map{ $_ =~ s{\A\Q$path_str\E/?}{}; $_ => 1 } |
|
6
|
|
|
|
|
21
|
|
52
|
2
|
|
|
|
|
2922
|
grep{ $_ !~ /\.git|CVS|svn/ }@files_in_fs; |
|
6
|
|
|
|
|
29
|
|
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
18
|
delete $fs{ $sopm_path->basename }; |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
38
|
my $root_elem = $tree->getDocumentElement; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# retrieve file information |
59
|
2
|
|
|
|
|
22
|
my @files = $root_elem->findnodes( 'Filelist/File' ); |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
220
|
my @not_found; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
FILE: |
64
|
2
|
|
|
|
|
7
|
for my $file ( @files ) { |
65
|
4
|
|
|
|
|
23
|
my $name = $file->findvalue( '@Location' ); |
66
|
|
|
|
|
|
|
|
67
|
4
|
100
|
|
|
|
535
|
push @not_found, $name if !delete $fs{$name}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
2
|
100
|
|
|
|
9
|
if ( @not_found ) { |
71
|
|
|
|
|
|
|
print "Files listed in .sopm but not found on disk:\n", |
72
|
1
|
|
|
|
|
2
|
map{ " - $_\n" }@not_found; |
|
2
|
|
|
|
|
57
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
2
|
100
|
|
|
|
20
|
if ( %fs ) { |
76
|
|
|
|
|
|
|
print "Files found on disk but not listed in .sopm:\n", |
77
|
1
|
|
|
|
|
6
|
map{ " - $_\n" }sort keys %fs; |
|
2
|
|
|
|
|
30
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |