| 1 | package VCS::Which::Plugin::CVS; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | # Created on: 2009-05-16 16:58:14 | ||||||||||||||||||||||||||||||||
| 4 | # Create by: ivan | ||||||||||||||||||||||||||||||||
| 5 | # $Id$ | ||||||||||||||||||||||||||||||||
| 6 | # $Revision$, $HeadURL$, $Date$ | ||||||||||||||||||||||||||||||||
| 7 | # $Revision$, $Source$, $Date$ | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use version; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Data::Dumper qw/Dumper/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use English qw/ -no_match_vars /; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use File::chdir; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Contextual::Return; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 2 | extends 'VCS::Which::Plugin'; | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 2 | our $VERSION = version->new('0.6.9'); | |||||||||||||||||||||||||||||||
| 23 | 2 | our $name = 'CVS'; | |||||||||||||||||||||||||||||||
| 24 | 2 | our $exe = 'cvs'; | |||||||||||||||||||||||||||||||
| 25 | 2 | our $meta = 'CVS'; | |||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | sub installed { | ||||||||||||||||||||||||||||||
|
Subroutine
installed: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 28 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 6 | ▶ | return $self->_installed if defined $self->_installed; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 1 | for my $path (split /[:;]/, $ENV{PATH}) { | |||||||||||||||||||||||||||||||
| 33 | 10 | ▶ | next if !-x "$path/$exe"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 0 | return $self->_installed( 1 ); | |||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 1 | return $self->_installed( 0 ); | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 21 | ▶ | sub used { | ||||||||||||||||||||||||||||||
|
Subroutine
used: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 42 | 21 | my ( $self, $dir ) = @_; | |||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 21 | ▶ | if (-f $dir) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | 0 | $dir = path($dir)->parent; | |||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 21 | ▶ | croak "$dir is not a directory!" if !-d $dir; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 20 | return -d "$dir/$meta"; | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub uptodate { | ||||||||||||||||||||||||||||||
|
Subroutine
uptodate: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 54 | 0 | my ( $self, $dir ) = @_; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $dir ||= $self->_base; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$dir ||= $self->_base
MC/DC0%0/2
$dir ||= $self->_base
$dir
$self->_base
Truth table0%0/3
A ||= B
A= $dirB= $self->_base
| |||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | croak "'$dir' is not a directory!" if !-e $dir; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 0 | chdir $dir; | |||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 0 | return !grep {!/Up-to-date/} grep { /Status:/ } `$exe status 2>/dev/null`; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub pull { | ||||||||||||||||||||||||||||||
|
Subroutine
pull: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 66 | 0 | my ( $self, $dir ) = @_; | |||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $dir ||= $self->_base; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$dir ||= $self->_base
MC/DC0%0/2
$dir ||= $self->_base
$dir
$self->_base
Truth table0%0/3
A ||= B
A= $dirB= $self->_base
| |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | croak "'$dir' is not a directory!" if !-e $dir; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 0 | local $CWD = $dir; | |||||||||||||||||||||||||||||||
| 73 | 0 | return !system "$exe update > /dev/null 2> /dev/null"; | |||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub cat { | ||||||||||||||||||||||||||||||
|
Subroutine
cat: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 77 | 0 | my ($self, $file, $revision) = @_; | |||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ( $revision && $revision =~ /^-\d+$/xms ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$revision and $revision =~ /^-\d+$/msx
MC/DC0%0/2
$revision and $revision =~ /^-\d+$/msx
$revision
$revision =~ /^-\d+$/msx
Truth table0%0/3
A and B
A= $revisionB= $revision =~ /^-\d+$/msx
| |||||||||||||||||||||||||||||||||
| 80 | 0 | my @versions = reverse `$exe log -q $file` =~ /^ revision \s+ (\d+[.]\d+)/gxms; | |||||||||||||||||||||||||||||||
| 81 | 0 | $revision = $versions[$revision]; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | elsif ( !defined $revision ) { | ||||||||||||||||||||||||||||||||
| 84 | 0 | $revision = ''; | |||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $revision &&= "-r $revision"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$revision &&= "-r $revision"
MC/DC0%0/1
$revision &&= "-r $revision"
$revision
Truth table0%0/2
A
A= $revision
| |||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 0 | return `$exe update -p $revision $file`; | |||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub log { | ||||||||||||||||||||||||||||||
|
Subroutine
log: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 93 | 0 | my ($self, $file, @args) = @_; | |||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 0 | my $args = join ' ', @args; | |||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $dir = -d $file ? path($file) : path($file)->parent; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | 0 | local $CWD = $dir; | |||||||||||||||||||||||||||||||
| 99 | return | ||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | SCALAR { scalar `$exe log $args` } | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | ARRAYREF { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 102 | 0 | my $logs = `$exe $args log 2> /dev/null`; | |||||||||||||||||||||||||||||||
| 103 | 0 | my @logs; | |||||||||||||||||||||||||||||||
| 104 | 0 | for my $file ( split /^={77}$/xms, $logs ) { | |||||||||||||||||||||||||||||||
| 105 | 0 | my ($details, @log) = split /^-{28}$/xms, $file; | |||||||||||||||||||||||||||||||
| 106 | 0 | push @logs, @log; | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 0 | return \@logs; | |||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | HASHREF { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 112 | 0 | my $logs = `$exe $args log 2> /dev/null`; | |||||||||||||||||||||||||||||||
| 113 | 0 | my %log_by_date; | |||||||||||||||||||||||||||||||
| 114 | 0 | for my $file ( split /^={77}$/xms, $logs ) { | |||||||||||||||||||||||||||||||
| 115 | 0 | my ($details, @log) = split /^-{28}$/xms, $file; | |||||||||||||||||||||||||||||||
| 116 | 0 | for my $log (@log) { | |||||||||||||||||||||||||||||||
| 117 | 0 | my (undef, $rev_line, $data_line, $description) = split /\r?\n/xms, $log, 4; | |||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 0 | chomp $description; | |||||||||||||||||||||||||||||||
| 120 | 0 | my ($rev) = $rev_line =~ /^revision \s+ ([\d.]+)$/xms; | |||||||||||||||||||||||||||||||
| 121 | 0 | my ($date, $author) = $data_line =~ /^date: \s* ([^;]+); \s* author: \s* ([^;]+)/xms; | |||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 0 | push @{ $log_by_date{$date} }, { | |||||||||||||||||||||||||||||||
| 124 | rev => $rev, | ||||||||||||||||||||||||||||||||
| 125 | description => $description, | ||||||||||||||||||||||||||||||||
| 126 | Date => $date, | ||||||||||||||||||||||||||||||||
| 127 | Author => $author, | ||||||||||||||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 0 | my %log; | |||||||||||||||||||||||||||||||
| 133 | 0 | my $i = 1; | |||||||||||||||||||||||||||||||
| 134 | 0 | for my $date ( sort keys %log_by_date ) { | |||||||||||||||||||||||||||||||
| 135 | 0 | $log{$i++} = $log_by_date{$date}[0]; | |||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||
| 137 | 0 | return \%log; | |||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | 0 | } | |||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 2 | 1; | |||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | __END__ | ||||||||||||||||||||||||||||||||