blib/lib/Git/Sub.pm

filter: Statementstmt 88.1% 37 / 42 Branchbran 60.0% 6 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 81.5% 53 / 65 SCAR 19.9
CC
7
Cov
82%
import
7.2
AUTOLOAD
2.0
BEGIN
1.0
CRAP 7.3
↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Git::Sub;
4 # ABSTRACT: git commands imported as System::Sub subs in git:: namespace
5 2 $Git::Sub::VERSION = '0.162920';
6 2 ▶use System::Sub ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use File::Which ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 my $GIT;
10  
11 sub import
12 {
13 2 ▶ return if @_ <= 1;
Subroutine import: called CC=6 SCAR=19.7
Branch: 1 branch
BranchTrueFalseTotal
if @_ <= 1 1 1 2
14 1 shift;
15  
16 1 ▶ if ($_[0] eq 'git') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] eq "git") 0 1 1
17 0 ▶ unless (@_ > 2) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_ > 2) 0 0 0
18 0 require Carp;
19 0 Carp::croak('missing value for "git" parameter');
20 }
21 0 $GIT = $_[1];
22 0 splice @_, 0, 2;
23 }
24  
25 # The remaining arguments are names of subs
26 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
28 1 my $fq_name = 'git::'.shift;
29 1 ▶ next if defined *{$fq_name};
Branch: 1 branch
BranchTrueFalseTotal
if defined *{$fq_name;} 0 1 1
30 # TODO: check names: /[a-z_]/
31 # See subs.pm
32 1 *{$fq_name} = \&{$fq_name};
33 }
34 }
35  
36 package # no indexing
37 git;
38  
39 use subs
40 # Common commands
41 2 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 2 ▶;
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 sub AUTOLOAD
62 {
63 14 ▶ my $git_cmd = our $AUTOLOAD;
Subroutine AUTOLOAD: called CC=2 SCAR=7.0
64 14 $git_cmd = substr($git_cmd, 1+rindex($git_cmd, ':'));
65 14 $git_cmd =~ tr/_/-/; # Seems to the first time I use tr// in the last 2 years
66 14 ▶ $GIT ||= File::Which::which('git');
Condition66%2/3
$GIT ||= File::Which::which("git")
l!l&&r!l&&!r
1310
MC/DC0%0/2
$GIT ||= File::Which::which("git")
$GIT File::Which::which("git")
Truth table66%2/3
A ||= B
A= $GITB= File::Which::which("git")
ABresult
1X1
011
000
67  
68 14 System::Sub->import($AUTOLOAD, [
69 '$0' => $GIT,
70 '@ARGV' => [ $git_cmd ],
71 ]);
72 14 goto &$AUTOLOAD
73 }
74  
75 2 1;
76 __END__
↑ Summary