lib/Git/Repo/Commits.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 2 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 100% 60 / 60 CC 4 SCAR 6.9
CC
4
Cov
100%
new
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
↑ Summary
1 package Git::Repo::Commits;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Git;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use version; our $VERSION = qv('0.1.1'); # Work with a few files
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # Other recommended modules (uncomment to use):
11 # use IO::Prompt;
12 # use Perl6::Export;
13 # use Perl6::Slurp;
14 # use Perl6::Say;
15  
16  
17 # Module implementation here
18 4 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
19 4 my $class = shift;
20 4 ▶ my $dir = shift || croak "Need a repo directory";
Condition100%2/2
shift() || croak('Need a repo directory')
l!l
31
MC/DC100%1/1
shift() || croak('Need a repo directory')
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
21 3 my $files_arrayref = shift;
22 3 my ($repo_name) = ($dir =~ m{/([^/]+)/?$} );
23 3 my $repo = Git->repository (Directory => $dir);
24 3 my @these_revs;
25 3 ▶ if ( $files_arrayref ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($files_arrayref) { } 1 2 3
26 1 @these_revs = $repo->command('rev-list', '--all', '--', join(" ", @$files_arrayref));
27 } else {
28 2 @these_revs = $repo->command('rev-list', '--all');
29 }
30 3 my @commit_info;
31 3 for my $commit ( reverse @these_revs ) {
32 6 my $commit_info = $repo->command('show', '--pretty=fuller', $commit);
33 6 my @files = ($commit_info =~ /\+\+\+\s+b\/(.+)/g);
34 6 my ($author) = ($commit_info =~ /Author:\s+(.+)/);
35 6 my ($commit) = ($commit_info =~ /Commit:\s+(.+)/);
36 6 my ($commit_date) = ($commit_info =~ /CommitDate:\s+(.+)/);
37 6 push @commit_info, { files => \@files,
38 author => $author,
39 commit => $commit,
40 commit_date => $commit_date};
41 }
42 3 my $commits = { _repo => $dir,
43 _name => $repo_name,
44 _commits => \@commit_info,
45 _hashes => \@these_revs};
46 3 return bless $commits, $class;
47  
48 }
49  
50 2 ▶sub commits {
Subroutine commits: called CC=1 SCAR=0.0
Pod documented
51 2 my $self = shift;
52 2 return $self->{'_commits'};
53 }
54  
55 2 ▶sub hashes {
Subroutine hashes: called CC=1 SCAR=0.0
Pod documented
56 2 my $self = shift;
57 2 return $self->{'_hashes'};
58 }
59  
60 2 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
61 2 my $self = shift;
62 2 return $self->{'_name'};
63 }
64
65  
66 1 1; # Magic true value required at end of module
67 __END__
↑ Summary