VCI/Abstract/Commit.pm

filter: Statementstmt 50.0% 26 / 52 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 20.0% 3 / 15 Podpod n/a totaltotal 40.8% 29 / 71 CC 4 SCAR 17.4
CC
4
Cov
46%
_build_uuid
20.0
_build_removed
2.0
_build_modified
2.0
CRAP 5.7
« VCI/VCS/Git/Project.pm ↑ Summary VCI/VCS/Cvs/Repository.pm »
1 package VCI::Abstract::Commit;
2 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use VCI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Digest::MD5 qw(md5_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # XXX ProjectItem should really be composed by FileContainer, but see the
7 # note there.
8 4 with 'VCI::Abstract::FileContainer', 'VCI::Abstract::ProjectItem';
9  
10 # All of this crazy init_arg stuff means "coerce lazily, because
11 # DateTime is slow."
12 has 'time' => (is => 'ro', isa => 'VCI::Type::DateTime', coerce => 1,
13 lazy => 1,
14 0 ▶ default => sub { shift->_time }, init_arg => '__time');
Subroutine __ANON__: not called CC=1 SCAR=1.2
15 4 has '_time' => (is => 'ro', isa => 'Defined', init_arg => 'time',
16 required => 1);
17  
18 4 has 'author' => (is => 'ro', isa => 'Str', lazy_build => 1);
19 0 ▶has 'committer' => (is => 'ro', isa => 'Str', default => sub { '' });
Subroutine __ANON__: not called CC=1 SCAR=1.2
20 4 has 'added' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Committable]',
21 lazy_build => 1);
22 4 has 'removed' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Committable]',
23 lazy_build => 1);
24 4 has 'modified' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Committable]',
25 lazy_build => 1);
26 4 has 'moved' => (is => 'ro', isa => 'HashRef[VCI::Abstract::Committable]',
27 lazy_build => 1);
28 4 has 'copied' => (is => 'ro', isa => 'HashRef[VCI::Abstract::Committable]',
29 lazy_build => 1);
30 4 has 'revision' => (is => 'ro', isa => 'Str', required => 1);
31 4 has 'revno' => (is => 'ro', isa => 'Str', lazy_build => 1);
32 # XXX Probably should also have shortmessage, which can be the "subject"
33 # for VCSes that store that, and the first line of the message for
34 # VCSes that don't.
35 0 ▶has 'message' => (is => 'ro', isa => 'Str', default => sub { '' });
Subroutine __ANON__: not called CC=1 SCAR=1.2
36 4 has 'uuid' => (is => 'ro', isa => 'Str', lazy_build => 1);
37  
38 4 has 'as_diff' => (is => 'ro', isa => 'VCI::Abstract::Diff', lazy_build => 1);
39  
40 0 ▶sub _build_removed { [] }
Subroutine _build_removed: not called CC=1 SCAR=6.9
41 0 ▶sub _build_modified { [] }
Subroutine _build_modified: not called CC=1 SCAR=6.9
42 0 ▶sub _build_moved { {} }
Subroutine _build_moved: not called CC=1 SCAR=6.9
43 0 ▶sub _build_copied { {} }
Subroutine _build_copied: not called CC=1 SCAR=6.9
44  
45 0 ▶sub _build_contents {
Subroutine _build_contents: not called CC=1 SCAR=6.9
46 0 my $self = shift;
47 0 return [@{$self->added}, @{$self->removed}, @{$self->modified}];
48 }
49  
50 0 ▶sub _build_author { shift->committer }
Subroutine _build_author: not called CC=1 SCAR=6.9
51 0 ▶sub _build_revno { shift->revision }
Subroutine _build_revno: not called CC=1 SCAR=6.9
52  
53 0 ▶sub _build_uuid {
Subroutine _build_uuid: not called CC=4 SCAR=30.0
54 0 my ($self) = @_;
55 0 ▶ if ($self->vci->revisions_are_universal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->vci->revisions_are_universal) 0 0 0
56 0 return $self->revision;
57 }
58  
59 0 my @pieces = ($self->_repository_for_uuid, $self->revision);
60 0 ▶ if (!$self->vci->revisions_are_global) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->vci->revisions_are_global) 0 0 0
61 0 push(@pieces, $self->project->name);
62 }
63 0 utf8::downgrade($_) foreach @pieces;
64 0 return md5_hex(@pieces);
65 }
66  
67 0 ▶sub _repository_for_uuid {
Subroutine _repository_for_uuid: not called CC=1 SCAR=6.9
68 0 my ($self) = @_;
69 # Many VCSes allow access over URIs, where you can specify
70 # a username and password in the URI. However, no matter what credentials
71 # you use to access a repository, it's still the same repo, so we
72 # shouldn't take those credentials into account when creating the UUID.
73 #
74 # bzr can have "+" in the protocol identifiers, so we allow that.
75 0 my $repo = $self->repository->root;
76 0 $repo =~ s{^([A-Za-z\+]+://)[^/]+@}{$1};
77 0 return $repo;
78 }
79  
80 # as_patch, as_bundle
81 # Also as_patch_binary, as_bundle_binary?
82 # And perhaps as_diff_from, as_bundle_from
83  
84 4 __PACKAGE__->meta->make_immutable;
85  
86 4 1;
87  
88 __END__
« VCI/VCS/Git/Project.pm ↑ Summary VCI/VCS/Cvs/Repository.pm »