line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
131698
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
2
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
3
|
|
|
|
|
|
|
package Git::Sub; |
4
|
|
|
|
|
|
|
# ABSTRACT: git commands imported as System::Sub subs in git:: namespace |
5
|
|
|
|
|
|
|
$Git::Sub::VERSION = '0.163130'; |
6
|
1
|
|
|
1
|
|
739
|
use System::Sub (); |
|
1
|
|
|
|
|
59269
|
|
|
1
|
|
|
|
|
34
|
|
7
|
1
|
|
|
1
|
|
12
|
use File::Which (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
114
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $GIT; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import |
12
|
|
|
|
|
|
|
{ |
13
|
2
|
100
|
|
2
|
|
751
|
return if @_ <= 1; |
14
|
1
|
|
|
|
|
3
|
shift; |
15
|
|
|
|
|
|
|
|
16
|
1
|
50
|
|
|
|
3
|
if ($_[0] eq 'git') { |
17
|
0
|
0
|
|
|
|
0
|
unless (@_ > 2) { |
18
|
0
|
|
|
|
|
0
|
require Carp; |
19
|
0
|
|
|
|
|
0
|
Carp::croak('missing value for "git" parameter'); |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
0
|
$GIT = $_[1]; |
22
|
0
|
|
|
|
|
0
|
splice @_, 0, 2; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# The remaining arguments are names of subs |
26
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
192
|
|
27
|
1
|
|
|
|
|
6
|
while (@_) { |
28
|
1
|
|
|
|
|
4
|
my $fq_name = 'git::'.shift; |
29
|
1
|
50
|
|
|
|
2
|
next if defined *{$fq_name}; |
|
1
|
|
|
|
|
26
|
|
30
|
|
|
|
|
|
|
# TODO: check names: /[a-z_]/ |
31
|
|
|
|
|
|
|
# See subs.pm |
32
|
1
|
|
|
|
|
2
|
*{$fq_name} = \&{$fq_name}; |
|
1
|
|
|
|
|
2042
|
|
|
1
|
|
|
|
|
6
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package # no indexing |
37
|
|
|
|
|
|
|
git; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use subs |
40
|
|
|
|
|
|
|
# Common commands |
41
|
1
|
|
|
|
|
10
|
qw(version |
42
|
|
|
|
|
|
|
commit tag push add rm branch checkout clone fetch init log |
43
|
|
|
|
|
|
|
mv notes pull push rebase reset revert status), |
44
|
|
|
|
|
|
|
# Ancillary commands |
45
|
|
|
|
|
|
|
qw(config filter_branch prune remote repack), |
46
|
|
|
|
|
|
|
# Interrogator |
47
|
|
|
|
|
|
|
qw(rev_parse), |
48
|
|
|
|
|
|
|
# Plumbing: manipulation commands |
49
|
|
|
|
|
|
|
qw(apply checkout_index commit_tree hash_object index_pack merge_file |
50
|
|
|
|
|
|
|
merge_index mktag mktree pack_objects prune_packed read_tree |
51
|
|
|
|
|
|
|
symbolic_ref unpack_objects update_index update_ref write_tree), |
52
|
|
|
|
|
|
|
# Plumbing: interrogation commands |
53
|
|
|
|
|
|
|
qw(cat_file diff_files diff_index diff_tree for_each_ref ls_files |
54
|
|
|
|
|
|
|
ls_remote ls_tree merge_base name_rev pack_redundant rev_list |
55
|
|
|
|
|
|
|
show_index show_ref tar_tree unpack_file var verify_pack), |
56
|
|
|
|
|
|
|
# Plumbing: synching repositories |
57
|
|
|
|
|
|
|
qw(fetch_pack send_pack update_server_info parse_remote receive_pack |
58
|
|
|
|
|
|
|
upload_archive upload_pack) |
59
|
1
|
|
|
1
|
|
905
|
; |
|
1
|
|
|
|
|
33
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub AUTOLOAD |
62
|
|
|
|
|
|
|
{ |
63
|
14
|
|
|
14
|
|
277660
|
my $git_cmd = our $AUTOLOAD; |
64
|
14
|
|
|
|
|
92
|
$git_cmd = substr($git_cmd, 1+rindex($git_cmd, ':')); |
65
|
14
|
|
|
|
|
42
|
$git_cmd =~ tr/_/-/; # Seems to the first time I use tr// in the last 2 years |
66
|
14
|
|
66
|
|
|
75
|
$GIT ||= File::Which::which('git'); |
67
|
|
|
|
|
|
|
|
68
|
14
|
|
|
|
|
426
|
System::Sub->import($AUTOLOAD, [ |
69
|
|
|
|
|
|
|
'$0' => $GIT, |
70
|
|
|
|
|
|
|
'@ARGV' => [ $git_cmd ], |
71
|
|
|
|
|
|
|
]); |
72
|
14
|
|
|
|
|
2332
|
goto &$AUTOLOAD |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=encoding UTF-8 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Git::Sub - git commands imported as L<System::Sub> subs in the git:: namespace |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 VERSION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
version 0.163130 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
use Git::Sub qw(clone tag push); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# Git commands are now Perl subs |
93
|
|
|
|
|
|
|
git::clone 'git://github.com/dolmen/p5-Git-Sub.git'; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
git::tag -a => -m => "Release v$version", "v$version"; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
git::push qw(--tags origin master); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Commands names with '-' are imported with '_' |
100
|
|
|
|
|
|
|
my $master = git::rev_parse 'release'; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Return in list context is lines (see System::Sub) |
103
|
|
|
|
|
|
|
say for git::ls_tree 'master'; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Process lines using a callback |
106
|
|
|
|
|
|
|
git::ls_tree 'master' => sub { |
107
|
|
|
|
|
|
|
my ($mode, $type, $object, $file) = split; |
108
|
|
|
|
|
|
|
say $file; |
109
|
|
|
|
|
|
|
}; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Use L<git|http://www.git-scm.com> commands easily from your Perl program. Each |
114
|
|
|
|
|
|
|
git command is imported as a L<System::Sub> DWIM sub. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 EXAMPLES |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=over 4 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The L<release script|https://github.com/dolmen/angel-PS1/blob/devel/dist> of |
123
|
|
|
|
|
|
|
my L<angel-PS1|https://github.com/dolmen/angel-PS1> project. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Olivier Mengué, C<dolmen@cpan.org>. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Copyright E<copy> 2016 Olivier Mengué. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
136
|
|
|
|
|
|
|
the same terms as Perl 5 itself. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# vim:set et sw=4 sts=4: |