| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# App::GitFind::Searcher::Git - Search for files in a Git index |
|
2
|
|
|
|
|
|
|
package App::GitFind::Searcher::Git; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1909
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
16
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
17
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use App::GitFind::Base; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
115
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000002'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use parent 'App::GitFind::Searcher'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
12
|
|
|
|
|
|
|
use Class::Tiny qw(repo searchbase), |
|
13
|
|
|
|
|
|
|
{ |
|
14
|
0
|
|
|
|
|
0
|
scan_submodules => sub { true }, |
|
15
|
1
|
|
|
1
|
|
98
|
}; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
14
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
465
|
use App::GitFind::Entry::GitIndex; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
17
|
|
|
18
|
1
|
|
|
1
|
|
436
|
use Git::Raw; |
|
|
1
|
|
|
|
|
23241
|
|
|
|
1
|
|
|
|
|
30
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use Git::Raw::Submodule; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
563
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Docs {{{1 |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
App::GitFind::Searcher::Git - Search for files on disk |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This is an L<App::GitFind::Searcher> that looks through a file system. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# }}}1 |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 run |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Conducts a search. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
|
44
|
0
|
|
|
0
|
1
|
|
my ($self, $callback) = @_; |
|
45
|
0
|
|
|
|
|
|
return $self->_run($callback, $self->repo); |
|
46
|
|
|
|
|
|
|
} #run() |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Implementation of run(). Call as $self->_run($callback, $repo). |
|
49
|
|
|
|
|
|
|
sub _run { |
|
50
|
0
|
|
|
0
|
|
|
my ($self, $callback, $repo) = @_; |
|
51
|
0
|
|
|
|
|
|
my $index = $repo->index; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my %submodules; # map submodule paths to Git::Raw::Submodule instances |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if($self->scan_submodules) { |
|
56
|
|
|
|
|
|
|
# Does $repo have submodules? (EXPERIMENTAL) |
|
57
|
0
|
|
|
|
|
|
my @submodule_names; |
|
58
|
|
|
|
|
|
|
Git::Raw::Submodule->foreach($repo, sub { |
|
59
|
0
|
|
|
0
|
|
|
push @submodule_names, $_[0]; |
|
60
|
0
|
|
|
|
|
|
return 0; # Tell foreach() to keep going |
|
61
|
0
|
|
|
|
|
|
}); |
|
62
|
0
|
0
|
|
0
|
|
|
vlog { "Submodules:", join ', ', @submodule_names } if @submodule_names; |
|
|
0
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Open the submodules |
|
65
|
0
|
|
|
|
|
|
for(@submodule_names) { |
|
66
|
0
|
|
|
|
|
|
my $sm = Git::Raw::Submodule->lookup($repo, $_); |
|
67
|
0
|
0
|
|
|
|
|
unless($sm) { |
|
68
|
0
|
|
|
0
|
|
|
vwarn { "Could not access submodule $_" }; # TODO die? |
|
|
0
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return undef; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
0
|
|
|
|
|
|
$submodules{$_} = $sm; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
for my $idxe ($index->entries) { |
|
76
|
0
|
|
|
|
|
|
my $entry = App::GitFind::Entry::GitIndex->new(-obj=>$idxe, |
|
77
|
|
|
|
|
|
|
-repo=>$repo, -searchbase=>$self->searchbase); |
|
78
|
0
|
|
|
|
|
|
$callback->($entry); |
|
79
|
|
|
|
|
|
|
# TODO prune and other control |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
if(my $sm = $submodules{$idxe->path}) { |
|
82
|
0
|
|
|
0
|
|
|
vlog { "Entering submodule", $sm->name } 2; |
|
|
0
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $smrepo = $sm->open; |
|
84
|
0
|
0
|
|
|
|
|
die "Could not open repo for submodule @{[$smrepo->name]}: $@" if $@; |
|
|
0
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->_run($callback, $smrepo); |
|
86
|
0
|
|
|
0
|
|
|
vlog { "Exiting submodule", $sm->name } 2; |
|
|
0
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Make sure everything is closed |
|
89
|
0
|
|
|
|
|
|
undef $smrepo; |
|
90
|
0
|
|
|
|
|
|
undef $sm; |
|
91
|
0
|
|
|
|
|
|
undef $submodules{$idxe->path}; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
undef $entry; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} #_run() |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 BUILD |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub BUILD { |
|
103
|
0
|
|
|
0
|
1
|
|
my ($self, $hrArgs) = @_; |
|
104
|
0
|
0
|
0
|
|
|
|
unless($self->searchbase && $self->repo && |
|
|
|
|
0
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$self->repo->DOES('Git::Raw::Repository')) { |
|
106
|
0
|
|
|
|
|
|
require Carp; |
|
107
|
0
|
0
|
|
|
|
|
Carp::croak 'Need a -searchbase' unless $self->searchbase; |
|
108
|
0
|
0
|
|
|
|
|
Carp::croak 'Need a -repo' unless $self->repo; |
|
109
|
0
|
0
|
|
|
|
|
Carp::croak 'Repo must be a Git::Raw::Repository' |
|
110
|
|
|
|
|
|
|
unless $self->repo->DOES('Git::Raw::Repository'); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} #BUILD() |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
__END__ |
|
116
|
|
|
|
|
|
|
# vi: set fdm=marker: # |