File Coverage

blib/lib/Group/Git/Cmd/Branch.pm
Criterion Covered Total %
statement 24 39 61.5
branch 0 14 0.0
condition 0 3 0.0
subroutine 8 9 88.8
pod 1 1 100.0
total 33 66 50.0


line stmt bran cond sub pod time code
1             package Group::Git::Cmd::Branch;
2              
3             # Created on: 2013-05-06 21:57:14
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   753 use Moo::Role;
  1         3  
  1         12  
10 1     1   2752 use strict;
  1         2  
  1         21  
11 1     1   6 use warnings;
  1         2  
  1         28  
12 1     1   7 use version;
  1         2  
  1         10  
13 1     1   74 use Carp;
  1         3  
  1         74  
14 1     1   7 use English qw/ -no_match_vars /;
  1         2  
  1         8  
15 1     1   410 use File::chdir;
  1         3  
  1         74  
16 1     1   7 use Getopt::Alt;
  1         3  
  1         32  
17              
18             our $VERSION = version->new('0.7.5');
19              
20             requires 'repos';
21             requires 'verbose';
22             requires 'test';
23              
24             my $opt = Getopt::Alt->new(
25             { help => __PACKAGE__, },
26             [ 'quote|q!', ]
27             );
28              
29             sub branch {
30 0     0 1   my ($self, $name) = @_;
31 0 0         return unless -d $name;
32              
33 0           my $repo = $self->repos->{$name};
34              
35 0           local $CWD = $name;
36 0           my $cmd = "git branch -a";
37 0 0         $cmd .= " | grep " . join ' ', map { $self->shell_quote } @ARGV if @ARGV;
  0            
38 0 0 0       print "$cmd\n" if $self->verbose || $self->test;
39 0 0         if ( !$self->test ) {
40 0 0         if ( @ARGV ) {
41 0           my $out = `$cmd`;
42 0 0         if ( $out !~ /^\s*$/xms ) {
43 0           return $out;
44             }
45             }
46             else {
47 0 0         return `$cmd` if !$self->test;
48             }
49             }
50              
51 0           return;
52             }
53              
54             1;
55              
56             __END__
57              
58             =head1 NAME
59              
60             Group::Git::Cmd::Branch - Show all branches with optional grepping
61              
62             =head1 VERSION
63              
64             This documentation refers to Group::Git::Cmd::Branch version 0.7.5.
65              
66              
67             =head1 SYNOPSIS
68              
69             use Group::Git::Cmd::Branch;
70              
71             # Brief but working code example(s) here showing the most common usage(s)
72             # This section will be as far as many users bother reading, so make it as
73             # educational and exemplary as possible.
74              
75              
76             =head1 DESCRIPTION
77              
78             =head1 SUBROUTINES/METHODS
79              
80             =over 4
81              
82             =item C<branch ($name)>
83              
84             Runs a git branch -a over each repository and if other arguments are supplied
85             the branch is pipped through grep with the other arguments
86              
87             eg $ group-git branch feature
88              
89             will return each repository that has that C<feature> branch
90              
91             =back
92              
93             =head1 DIAGNOSTICS
94              
95             =head1 CONFIGURATION AND ENVIRONMENT
96              
97             =head1 DEPENDENCIES
98              
99             =head1 INCOMPATIBILITIES
100              
101             =head1 BUGS AND LIMITATIONS
102              
103             There are no known bugs in this module.
104              
105             Please report problems to Ivan Wills (ivan.wills@gmail.com).
106              
107             Patches are welcome.
108              
109             =head1 AUTHOR
110              
111             Ivan Wills - (ivan.wills@gmail.com)
112              
113             =head1 LICENSE AND COPYRIGHT
114              
115             Copyright (c) 2013 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
116             All rights reserved.
117              
118             This module is free software; you can redistribute it and/or modify it under
119             the same terms as Perl itself. See L<perlartistic>. This program is
120             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
121             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
122             PARTICULAR PURPOSE.
123              
124             =cut