File Coverage

blib/lib/App/Git/Workflow/Command/Search.pm
Criterion Covered Total %
statement 21 30 70.0
branch 0 2 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 29 41 70.7


line stmt bran cond sub pod time code
1             package App::Git::Workflow::Command::Search;
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 1     1   1121 use strict;
  1         3  
  1         29  
10 1     1   6 use warnings;
  1         3  
  1         25  
11 1     1   6 use version;
  1         2  
  1         6  
12 1     1   66 use English qw/ -no_match_vars /;
  1         2  
  1         6  
13 1     1   362 use Term::ANSIColor qw/colored/;
  1         2  
  1         55  
14 1     1   8 use App::Git::Workflow;
  1         37  
  1         43  
15 1     1   7 use App::Git::Workflow::Command qw/get_options/;
  1         3  
  1         656  
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              
22             sub run {
23 0     0 1   get_options(
24             \%option,
25             'all|a',
26             'insensitive|i',
27             );
28              
29 0           my $search = shift @ARGV;
30 0           my @shas = map {/([a-fA-F\d]+)/; $1} `git rev-list --remotes`;
  0            
  0            
31              
32 0           for my $sha (@shas) {
33 0           my $log = `git log -n 1 --name-status --oneline $sha`;
34 0 0         if ( $log =~ /$search/ ) {
35 0           print "$sha\n";
36             }
37             }
38             }
39              
40             1;
41              
42             __DATA__
43              
44             =head1 NAME
45              
46             git-search - grep for branch names
47              
48             =head1 VERSION
49              
50             This documentation refers to git-search version 1.1.16
51              
52             =head1 SYNOPSIS
53              
54             git-search [--remote|-r|--all|-a] regex
55              
56             OPTIONS:
57             regex grep's perl (-P) regular expression
58             -r --remote List all remote branches
59             -a --all List all branches
60             -v Find all branches that don't match regex
61              
62             --verbose Show more detailed option
63             --version Prints the version information
64             --help Prints this help information
65             --man Prints the full documentation for git-search
66              
67             =head1 DESCRIPTION
68              
69             Short hand for running
70              
71             C<git branch (-r|-a)? | grep -P 'regex'>
72              
73             =head1 SUBROUTINES/METHODS
74              
75             =head2 C<run ()>
76              
77             Executes the git workflow command
78              
79             =head1 DIAGNOSTICS
80              
81             =head1 CONFIGURATION AND ENVIRONMENT
82              
83             =head1 DEPENDENCIES
84              
85             =head1 INCOMPATIBILITIES
86              
87             =head1 BUGS AND LIMITATIONS
88              
89             There are no known bugs in this module.
90              
91             Please report problems to Ivan Wills (ivan.wills@gmail.com).
92              
93             Patches are welcome.
94              
95             =head1 AUTHOR
96              
97             Ivan Wills - (ivan.wills@gmail.com)
98              
99             =head1 LICENSE AND COPYRIGHT
100              
101             Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
102             All rights reserved.
103              
104             This module is free software; you can redistribute it and/or modify it under
105             the same terms as Perl itself. See L<perlartistic>. This program is
106             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
107             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
108             PARTICULAR PURPOSE.
109              
110             =cut