| 1 | 4 | ▶ | use MooseX::Declare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | role Gitalist::Git::CollectionOfRepositories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | with Git::Gitalist::Serializable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | with Gitalist::Git::CollectionOfRepositories::Role::Context { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use MooseX::Types::Moose qw/ArrayRef/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Moose::Autobox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use aliased 'Git::Gitalist::Repository'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | requires 'debug_string'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | has repositories => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | isa => ArrayRef['Git::Gitalist::Repository'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | has export_ok => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | method get_repository (NonEmptySimpleStr $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.4
Subroutine
get_repository: called CC=2 SCAR=8.7
Subroutine
__ANON__: not called CC=2 SCAR=8.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $repo = $self->_get_repo_from_name($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | confess("Couldn't get_repository '$name' - not a valid git repository.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | unless $self->_is_git_repo($repo->path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return $repo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Determine whether a given directory is a git repo. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | method _is_git_repo ($dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_is_git_repo: called CC=6 SCAR=22.0
Subroutine
__ANON__: called CC=6 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 38 | ▶ | my $has_head = -f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
-f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD')
-f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD')
MC/DC50%1/2
-f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD')
-f $dir->file('HEAD')
-f $dir->file('.git', 'HEAD')
MC/DC50%1/2
-f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD')
-f $dir->file('HEAD')
-f $dir->file('.git', 'HEAD')
Truth table66%2/3
A || B
A= -f $dir->file('HEAD')B= -f $dir->file('.git', 'HEAD')
Truth table66%2/3
A || B
A= -f $dir->file('HEAD')B= -f $dir->file('.git', 'HEAD')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 38 | ▶ | my $eok_file = $self->export_ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | or return $has_head; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $is_visible = $eok_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%4/12
$eok_file && (-f $dir->file($eok_file) || -f $dir->file('.git', $eok_file))
-f $dir->file($eok_file) or -f $dir->file(".git", $eok_file)
$eok_file && (-f $dir->file($eok_file) || -f $dir->file('.git', $eok_file))
-f $dir->file($eok_file) or -f $dir->file(".git", $eok_file)
MC/DC33%1/3
$eok_file && (-f $dir->file($eok_file) || -f $dir->file('.git', $eok_file))
$eok_file
-f $dir->file($eok_file)
-f $dir->file(".git", $eok_file)
MC/DC0%0/3
$eok_file && (-f $dir->file($eok_file) || -f $dir->file('.git', $eok_file))
$eok_file
-f $dir->file($eok_file)
-f $dir->file(".git", $eok_file)
Truth table50%2/4
A && B or C
A= $eok_fileB= -f $dir->file($eok_file)C= -f $dir->file(".git", $eok_file)
Truth table0%0/4
A && B or C
A= $eok_fileB= -f $dir->file($eok_file)C= -f $dir->file(".git", $eok_file)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | && (-f $dir->file($eok_file) || -f $dir->file('.git', $eok_file)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | return $has_head && $is_visible; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$has_head && $is_visible
$has_head && $is_visible
MC/DC50%1/2
$has_head && $is_visible
$has_head
$is_visible
MC/DC0%0/2
$has_head && $is_visible
$has_head
$is_visible
Truth table66%2/3
A && B
A= $has_headB= $is_visible
Truth table0%0/3
A && B
A= $has_headB= $is_visible
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | requires qw/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | _build_repositories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | _get_repo_from_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | around _build_repositories { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | [sort { $a->name cmp $b->name } $self->$orig->flatten]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | Gitalist::Git::CollectionOfRepositories - Interface and partial implementation of a collection of git repositories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | package My::Example::CollectionOfRepositories; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | with 'Gitalist::Git::CollectionOfRepositories'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | sub _build_repositories { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | [ $self->get_repository('Gitalist') ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub _get_path_for_repository_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | my ($self, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | '/var/example/' . $name . '.git'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | my $collection = My::Example::CollectionOfRepositories->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | my $repository_list = $collection->repositories; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | my $only_repository = $repository_list->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | my $named_repository = $repo->get_repository('Gitalist'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | This role provides an abstraction for a list of Repository directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | =head2 repositories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | An array of all L<Git::Gitalist::Repository>s. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | =head2 get_repository (Str $name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | Returns a L<Git::Gitalist::Repository> for the given name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | If C<$name> is not a valid git repository an exception will be thrown. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | L<Gitalist::Git::CollectionOfRepositories::FromListOfDirectories>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | L<Gitalist::Git::CollectionOfRepositories::FromDirectory>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | L<Git::Gitalist::Repository>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | See L<Gitalist> for authors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | See L<Gitalist> for the license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||