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