line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Group::Git::Cmd::Grep; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2013-05-06 21:57:07 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
972
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
10
|
1
|
|
|
1
|
|
2835
|
use strict; |
|
1
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
26
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
12
|
1
|
|
|
1
|
|
6
|
use version; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
13
|
1
|
|
|
1
|
|
76
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
129
|
|
14
|
1
|
|
|
1
|
|
28
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
15
|
1
|
|
|
1
|
|
444
|
use File::chdir; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
16
|
1
|
|
|
1
|
|
7
|
use Getopt::Alt; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = version->new('0.7.5'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
requires 'repos'; |
21
|
|
|
|
|
|
|
requires 'verbose'; |
22
|
|
|
|
|
|
|
requires 'shell_quote'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $opt = Getopt::Alt->new( |
25
|
|
|
|
|
|
|
{ help_package => __PACKAGE__, }, |
26
|
|
|
|
|
|
|
[ |
27
|
|
|
|
|
|
|
'text|a', |
28
|
|
|
|
|
|
|
'I', |
29
|
|
|
|
|
|
|
'textconv', |
30
|
|
|
|
|
|
|
'ignore-case|i', |
31
|
|
|
|
|
|
|
'word-regexp|w', |
32
|
|
|
|
|
|
|
'invert-match|v', |
33
|
|
|
|
|
|
|
'h', |
34
|
|
|
|
|
|
|
'H', |
35
|
|
|
|
|
|
|
'full-name', |
36
|
|
|
|
|
|
|
'extended-regexp|E', |
37
|
|
|
|
|
|
|
'basic-regexp|G', |
38
|
|
|
|
|
|
|
'perl-regexp|P', |
39
|
|
|
|
|
|
|
'fixed-strings|F', |
40
|
|
|
|
|
|
|
'line-number|n', |
41
|
|
|
|
|
|
|
'files-with-matches|l', |
42
|
|
|
|
|
|
|
'files-without-match|L', |
43
|
|
|
|
|
|
|
'open-files-in-pager|O=s', |
44
|
|
|
|
|
|
|
'null|z', |
45
|
|
|
|
|
|
|
'count|c', |
46
|
|
|
|
|
|
|
'all-match', |
47
|
|
|
|
|
|
|
'quiet|q', |
48
|
|
|
|
|
|
|
'max-depth=i', |
49
|
|
|
|
|
|
|
'color=s?', |
50
|
|
|
|
|
|
|
'no-color', |
51
|
|
|
|
|
|
|
'break', |
52
|
|
|
|
|
|
|
'heading', |
53
|
|
|
|
|
|
|
'show-function|p', |
54
|
|
|
|
|
|
|
'A=s', |
55
|
|
|
|
|
|
|
'B=s', |
56
|
|
|
|
|
|
|
'C=s', |
57
|
|
|
|
|
|
|
'function-context|W', |
58
|
|
|
|
|
|
|
'threads=s', |
59
|
|
|
|
|
|
|
'f=s', |
60
|
|
|
|
|
|
|
'e=s', |
61
|
|
|
|
|
|
|
'and', |
62
|
|
|
|
|
|
|
'or', |
63
|
|
|
|
|
|
|
'not', |
64
|
|
|
|
|
|
|
'exclude-standard!', |
65
|
|
|
|
|
|
|
'cached', |
66
|
|
|
|
|
|
|
'no-index', |
67
|
|
|
|
|
|
|
'untracked', |
68
|
|
|
|
|
|
|
'branches|b', |
69
|
|
|
|
|
|
|
'verbose', |
70
|
|
|
|
|
|
|
] |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub grep_start { |
74
|
0
|
|
|
0
|
1
|
|
$opt->process; |
75
|
0
|
0
|
|
|
|
|
if ( ! @ARGV ) { |
76
|
0
|
|
|
|
|
|
$opt->_show_help(1, "Nothing to search!"); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub grep { |
83
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
84
|
0
|
0
|
|
|
|
|
return unless -d $name; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $repo = $self->repos->{$name}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
local $CWD = $name; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $cmd = 'git grep'; |
91
|
0
|
|
|
|
|
|
for my $arg ( keys %{ $opt->opt } ) { |
|
0
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
next if grep { $_ eq $arg } qw/verbose branches/; |
|
0
|
|
|
|
|
|
|
93
|
0
|
0
|
0
|
|
|
|
$cmd .= ( length $arg == 1 ? " -$arg" : " --$arg" ) . ( $arg eq 'max-depth' || $opt->opt->{$arg} ne 1 ? '=' . $opt->opt->{$arg} : '' ); |
|
|
0
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my @argv = @ARGV; |
97
|
0
|
0
|
|
|
|
|
if ( @argv ) { |
98
|
0
|
|
|
|
|
|
$cmd .= ' -- ' . join ' ', map { $self->shell_quote($_) } @argv; |
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
warn "$cmd\n" if $opt->opt->{verbose}; |
102
|
0
|
|
|
|
|
|
return scalar `$cmd`; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 NAME |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Group::Git::Cmd::Grep - Quick state of each repository (branch name and changes) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 VERSION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This documentation refers to Group::Git::Cmd::Grep version 0.7.5. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SYNOPSIS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
group-git grep |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This command allows the quick finding out of state (i.e. the branch name and |
124
|
|
|
|
|
|
|
weather there are uncommitted changes) for each repository. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item C<grep_start ()> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Initializes the command |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item C<grep ($name)> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Shows the repository branch and weather there are changes in it. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item C<grep_start ()> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Process the command line arguments for grep |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=back |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
There are no known bugs in this module. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Patches are welcome. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright (c) 2013 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
167
|
|
|
|
|
|
|
All rights reserved. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
170
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
171
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
172
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
173
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |