| 1 | package Git::Diff; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use Git; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use 5.018; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | $Git::Diff::VERSION = '0.000101'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | sub new { | ||||||||||||||||||||
| 12 | 1 | ▶ | my $s_class = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 13 | 1 | return bless {@_}, $s_class; | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | sub _repository { | ||||||||||||||||||||
| 17 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
_repository: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 18 | 0 | ▶ | $self->{_repository} //= Git->repository( %{$self} ); | ||||||||||||||||||
|
Condition0%0/3
$self->{"_repository"} //= "Git"->repository(%{$self;})
MC/DC0%0/2
$self->{"_repository"} //= "Git"->repository(%{$self;})
$self->{"_repository"}
"Git"->repository(%{$self;})
Truth table0%0/3
A //= B
A= $self->{"_repository"}B= "Git"->repository(%{$self;})
| |||||||||||||||||||||
| 19 | 0 | return $self->{_repository}; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | sub changes_by_line { | ||||||||||||||||||||
| 23 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
changes_by_line: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||
| 24 | 0 | my $hr_files = $self->changed_lines(); | |||||||||||||||||||
| 25 | 0 | for my $s_file ( keys %{$hr_files} ) { | |||||||||||||||||||
| 26 | 0 | my $hr_changed_lines = $hr_files->{$s_file}->{changed}; | |||||||||||||||||||
| 27 | 0 | for my $s_line_key ( keys %{$hr_changed_lines} ) { | |||||||||||||||||||
| 28 | 0 | my ( $i_subtraction, $i_addition ) = ( $s_line_key =~ m/\-(\d+)(?:,\d+)*\s\+(\d+)/ ); | |||||||||||||||||||
| 29 | 0 | for my $s_changed_line ( split /^/, $hr_changed_lines->{$s_line_key} ) { | |||||||||||||||||||
| 30 | 0 | ▶ | if ( $s_changed_line =~ /^\+(.*)/ ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | 0 | $hr_files->{$s_file}->{addition}->{ $i_addition++ } = $1; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | elsif ( $s_changed_line =~ /^\-(.*)/ ) { | ||||||||||||||||||||
| 34 | 0 | $hr_files->{$s_file}->{subtraction}->{ $i_subtraction++ } = $1; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | 0 | return $hr_files; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | sub changed_lines { | ||||||||||||||||||||
| 43 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
changed_lines: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 44 | 0 | ▶ | my $s_gitresult = $self->diff( $self->{base_branch} // 'master', '-U0' ); | ||||||||||||||||||
|
Condition0%0/2
$self->{"base_branch"} // "master"
MC/DC0%0/1
$self->{"base_branch"} // "master"
$self->{"base_branch"}
Truth table0%0/2
A
A= $self->{"base_branch"}
| |||||||||||||||||||||
| 45 | 0 | my @a_splitted = split /^diff /ms, $s_gitresult; | |||||||||||||||||||
| 46 | 0 | shift @a_splitted; | |||||||||||||||||||
| 47 | 0 | my $hr_files = {}; | |||||||||||||||||||
| 48 | 0 | for my $s_line (@a_splitted) { | |||||||||||||||||||
| 49 | 0 | my ($s_file_name) = ( $s_line =~ m/^--git .* b\/(.*)/ ); | |||||||||||||||||||
| 50 | 0 | my @a_lines = split /@@\s+/, $s_line; | |||||||||||||||||||
| 51 | 0 | ▶ | shift @a_lines if scalar @a_lines % 2 == 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 0 | my %h_changed_lines = @a_lines; | |||||||||||||||||||
| 53 | 0 | $hr_files->{$s_file_name} = { raw => $_, changed => \%h_changed_lines }; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | 0 | return $hr_files; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | sub diff { | ||||||||||||||||||||
| 59 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
diff: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 60 | 0 | my @a_command_params = @_; | |||||||||||||||||||
| 61 | 0 | unshift @a_command_params, 'diff'; | |||||||||||||||||||
| 62 | 0 | return $self->_repository->command(@a_command_params); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 1 | 1; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||