line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Git::Workflow::Command::TagGrep; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2014-03-11 20:58:59 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
85229
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
56
|
|
10
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
11
|
2
|
|
|
2
|
|
374
|
use version; |
|
2
|
|
|
|
|
1588
|
|
|
2
|
|
|
|
|
11
|
|
12
|
2
|
|
|
2
|
|
566
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
3106
|
|
|
2
|
|
|
|
|
9
|
|
13
|
2
|
|
|
2
|
|
1306
|
use Term::ANSIColor qw/colored/; |
|
2
|
|
|
|
|
7342
|
|
|
2
|
|
|
|
|
1581
|
|
14
|
2
|
|
|
2
|
|
406
|
use App::Git::Workflow; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
89
|
|
15
|
2
|
|
|
2
|
|
380
|
use App::Git::Workflow::Command qw/get_options/; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1074
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = version->new(1.1.16); |
18
|
|
|
|
|
|
|
our $workflow = App::Git::Workflow->new; |
19
|
|
|
|
|
|
|
our ($name) = $PROGRAM_NAME =~ m{^.*/(.*?)$}mxs; |
20
|
|
|
|
|
|
|
our %option = ( |
21
|
|
|
|
|
|
|
master => 'origin/master', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub run { |
25
|
4
|
|
|
4
|
1
|
29
|
get_options( |
26
|
|
|
|
|
|
|
\%option, |
27
|
|
|
|
|
|
|
'search|s=s', |
28
|
|
|
|
|
|
|
'colour|color|c', |
29
|
|
|
|
|
|
|
'insensitive|i', |
30
|
|
|
|
|
|
|
'unmerged|u!', |
31
|
|
|
|
|
|
|
'master|m=s', |
32
|
|
|
|
|
|
|
'limit|n=i', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
100
|
|
|
16
|
$ARGV[0] ||= ''; |
36
|
4
|
100
|
|
|
|
14
|
my $grep = $option{insensitive} ? "(?i:$ARGV[0])" : $ARGV[0]; |
37
|
4
|
|
|
|
|
8
|
shift @ARGV; |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
10
|
my $count = 1; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
28
|
for my $tag ( sort {_sorter()} grep {/$grep/} $workflow->git->tag ) { |
|
4
|
|
|
|
|
10
|
|
|
11
|
|
|
|
|
100
|
|
42
|
6
|
50
|
|
|
|
24
|
if ( $option{unmerged} ) { |
43
|
0
|
0
|
|
|
|
0
|
next if unmerged($tag, $option{master}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
6
|
50
|
33
|
|
|
16
|
last if $option{limit} && $count++ > $option{limit}; |
47
|
|
|
|
|
|
|
|
48
|
6
|
50
|
|
|
|
14
|
if (@ARGV) { |
49
|
0
|
|
|
|
|
0
|
my $shown = 0; |
50
|
0
|
|
|
|
|
0
|
for my $file (@ARGV) { |
51
|
|
|
|
|
|
|
my @contents = map { |
52
|
0
|
|
|
|
|
0
|
my $found = $_; |
53
|
0
|
0
|
|
|
|
0
|
if ($option{colour}) { |
54
|
0
|
|
|
|
|
0
|
$found =~ s/($grep)/colored ['red'], $1/egxms; |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
$found |
57
|
0
|
|
|
|
|
0
|
} |
58
|
0
|
|
|
|
|
0
|
grep {/$option{search}/} |
|
0
|
|
|
|
|
0
|
|
59
|
|
|
|
|
|
|
`git show $tag:$file`; |
60
|
0
|
0
|
|
|
|
0
|
if (@contents) { |
61
|
0
|
0
|
|
|
|
0
|
if (!$shown++) { |
62
|
0
|
|
|
|
|
0
|
print "$tag\n"; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
0
|
print " $file\n"; |
65
|
0
|
|
|
|
|
0
|
print @contents; |
66
|
0
|
|
|
|
|
0
|
print "\n"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
6
|
50
|
|
|
|
16
|
if ( $option{colour} ) { |
72
|
0
|
|
|
|
|
0
|
$tag =~ s/($grep)/colored ['red'], $1 /egxms; |
|
0
|
|
|
|
|
0
|
|
73
|
|
|
|
|
|
|
} |
74
|
6
|
|
|
|
|
285
|
print "$tag\n"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _sorter { |
80
|
2
|
|
|
2
|
|
16
|
no warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
606
|
|
81
|
4
|
|
|
4
|
|
6
|
my $A = $a; |
82
|
4
|
|
|
|
|
6
|
my $B = $b; |
83
|
4
|
|
|
|
|
13
|
$A =~ s/(\d+)/sprintf "%06d", $1/egxms; |
|
2
|
|
|
|
|
14
|
|
84
|
4
|
|
|
|
|
7
|
$B =~ s/(\d+)/sprintf "%06d", $1/egxms; |
|
2
|
|
|
|
|
8
|
|
85
|
4
|
|
|
|
|
13
|
$A cmp $B; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my %dest; |
89
|
|
|
|
|
|
|
sub unmerged { |
90
|
0
|
|
|
0
|
1
|
|
my ($source, $dest) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if ( ! $dest{$dest} ) { |
93
|
0
|
|
|
|
|
|
@{$dest{$dest}} = map {/^(.*)\n/; $1} `git log --format=format:%H $dest`; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
die "No destination branch commits for '$dest'" if !@{$dest{$dest}}; |
|
0
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $source_sha = `git log --format=format:%H -n 1 $source`; |
98
|
0
|
|
|
|
|
|
chomp $source_sha; |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
return scalar grep {$_ && $_ eq $source_sha} @{$dest{$dest}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__DATA__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
git-tag-grep - grep tags (and optionally files with them) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 VERSION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This documentation refers to git-tag-grep version 1.1.16 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SYNOPSIS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
git-tag-grep [option] regex |
118
|
|
|
|
|
|
|
git-tag-grep ((-s|--search) regex) [option] regex -- file(s) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
OPTIONS: |
121
|
|
|
|
|
|
|
regex grep's perl (-P) regular expression |
122
|
|
|
|
|
|
|
file When a file is specified the regexp will be run on the file |
123
|
|
|
|
|
|
|
not the tag name. |
124
|
|
|
|
|
|
|
-v Find all tags that don't match regex |
125
|
|
|
|
|
|
|
-u --unmerged |
126
|
|
|
|
|
|
|
Only show tags not merged to --master |
127
|
|
|
|
|
|
|
--no-unmerged |
128
|
|
|
|
|
|
|
Only show tags merged to master |
129
|
|
|
|
|
|
|
-m --master[=]str |
130
|
|
|
|
|
|
|
Branch to check against for --unmerged and --no-unmerged |
131
|
|
|
|
|
|
|
(Default origin/master) |
132
|
|
|
|
|
|
|
-n --limit[=]int |
133
|
|
|
|
|
|
|
Limit the out put to this number |
134
|
|
|
|
|
|
|
-s --search[=]regex |
135
|
|
|
|
|
|
|
Search term for looking within files |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
--verbose Show more detailed option |
138
|
|
|
|
|
|
|
--version Prints the version information |
139
|
|
|
|
|
|
|
--help Prints this help information |
140
|
|
|
|
|
|
|
--man Prints the full documentation for git-tag-grep |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Note: to search in all tags set the regex to '' |
143
|
|
|
|
|
|
|
eg git tag-grep --search thin '' -- file1 file2 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 DESCRIPTION |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Short hand for running |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
C<git tag | grep -P 'regex'> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 C<run ()> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Executes the git workflow command |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 C<unmerged ($source, $dest)> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Check if there are any commits in C<$source> that are not in C<$dest> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
There are no known bugs in this module. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Patches are welcome. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 AUTHOR |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
184
|
|
|
|
|
|
|
All rights reserved. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
187
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
188
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
189
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
190
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |