line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Group::Git::Cmd::Sh; |
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
|
|
2640
|
use Moo::Role; |
|
1
|
|
|
|
|
9879
|
|
|
1
|
|
|
|
|
10
|
|
10
|
1
|
|
|
1
|
|
456
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
20
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
12
|
1
|
|
|
1
|
|
6
|
use version; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
13
|
1
|
|
|
1
|
|
96
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
113
|
|
14
|
1
|
|
|
1
|
|
7
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
15
|
1
|
|
|
1
|
|
533
|
use File::chdir; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
81
|
|
16
|
1
|
|
|
1
|
|
782
|
use Getopt::Alt; |
|
1
|
|
|
|
|
746069
|
|
|
1
|
|
|
|
|
7
|
|
17
|
1
|
|
|
1
|
|
2195
|
use Path::Tiny; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
503
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = version->new('0.7.6'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
requires 'repos'; |
22
|
|
|
|
|
|
|
requires 'verbose'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $opt = Getopt::Alt->new( |
25
|
|
|
|
|
|
|
{ help => __PACKAGE__, }, |
26
|
|
|
|
|
|
|
[ |
27
|
|
|
|
|
|
|
'file|f=s', |
28
|
|
|
|
|
|
|
'quote|q!', |
29
|
|
|
|
|
|
|
'interactive|i', |
30
|
|
|
|
|
|
|
] |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub sh_start { |
34
|
0
|
|
|
0
|
1
|
|
$opt->process; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
0
|
|
|
|
if ( $opt->opt->file && -x $opt->opt->file ) { |
37
|
0
|
|
|
|
|
|
$opt->opt->file( '' . path($opt->opt->file)->absolute); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub sh { |
44
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
45
|
0
|
0
|
|
|
|
|
return unless -d $name; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $repo = $self->repos->{$name}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
local $CWD = $name; |
50
|
|
|
|
|
|
|
my $cmd |
51
|
|
|
|
|
|
|
= $opt->opt->file ? $opt->opt->file |
52
|
0
|
0
|
|
|
|
|
: $opt->opt->quote ? join ' ', map { $self->shell_quote } @ARGV |
|
0
|
0
|
|
|
|
|
|
53
|
|
|
|
|
|
|
: join ' ', @ARGV; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
local $ENV{GROUP_GIT_NAME} = $name; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if ($opt->opt->interactive) { |
58
|
0
|
|
|
|
|
|
system $cmd; |
59
|
0
|
|
|
|
|
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $out = `$cmd`; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
return $out if $self->verbose; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
0
|
|
|
|
return if !$out || $out =~ /\A\s*\Z/xms; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $out; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Group::Git::Cmd::Sh - Runs shell script in each git project |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This documentation refers to Group::Git::Cmd::Sh version 0.7.6. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
group-get sh program ... |
86
|
|
|
|
|
|
|
group-git sh [--quote|-q] program ... |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
OPTIONS: |
89
|
|
|
|
|
|
|
-q --quote Quote the program arguments before running saves you from |
90
|
|
|
|
|
|
|
having to work out the next level quoting but stops you from |
91
|
|
|
|
|
|
|
using other shell options eg piping (|). |
92
|
|
|
|
|
|
|
-i --interactive |
93
|
|
|
|
|
|
|
Stops capturing STDOUT so that interactive programs will |
94
|
|
|
|
|
|
|
work as expected eg if program is bash this will let you |
95
|
|
|
|
|
|
|
see the results of commands run |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Run the program in each checked out git repository. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item C<sh ($name)> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Runs all the reset of the command line in each directory as a shell script. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item C<sh_start ()> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Process the command line arguments for sh |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
There are no known bugs in this module. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Patches are welcome. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Copyright (c) 2013 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
138
|
|
|
|
|
|
|
All rights reserved. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
141
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
142
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
143
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
144
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |