line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Database::Role::RefReader; |
2
|
|
|
|
|
|
|
$Git::Database::Role::RefReader::VERSION = '0.011'; |
3
|
7
|
|
|
7
|
|
3948
|
use Moo::Role; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
47
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
requires |
6
|
|
|
|
|
|
|
'refs', |
7
|
|
|
|
|
|
|
; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# basic implementations |
10
|
|
|
|
|
|
|
sub ref_names { |
11
|
42
|
|
|
42
|
1
|
322
|
my ( $self, $type ) = @_; |
12
|
|
|
|
|
|
|
return $type |
13
|
28
|
|
|
|
|
132
|
? sort grep m{^refs/\Q$type\E/}, keys %{ $self->refs } |
14
|
42
|
100
|
|
|
|
287
|
: sort keys %{ $self->refs }; |
|
14
|
|
|
|
|
72
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
76
|
|
|
76
|
1
|
389184
|
sub ref_digest { $_[0]->refs->{ $_[1] } } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=pod |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Git::Database::Role::RefReader - Abstract role for Git backends that read references |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 VERSION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
version 0.011 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
package MyGitBackend; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use Moo; |
38
|
|
|
|
|
|
|
use namespace::clean; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
with |
41
|
|
|
|
|
|
|
'Git::Database::Role::Backend', |
42
|
|
|
|
|
|
|
'Git::Database::Role::RefReader'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# implement the required methods |
45
|
|
|
|
|
|
|
sub refs { ... } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
A L<backend|Git::Database::Role::Backend> doing the additional |
50
|
|
|
|
|
|
|
Git::Database::Role::RefReader role is capable of reading references |
51
|
|
|
|
|
|
|
from a Git repository and return information about them. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 refs |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $refs = $backend->refs; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Return a hash reference mapping all the (fully qualified) refnames in |
60
|
|
|
|
|
|
|
the repository to the corresponding digests (including C<HEAD>). |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 ref_names |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my @refs = $backend->ref_names; |
67
|
|
|
|
|
|
|
my @heads = $backend->ref_names('heads'); |
68
|
|
|
|
|
|
|
my @remotes = $backend->ref_names('remotes'); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Return the list of refnames in the repository. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The optional argument is used to limit the list of returned names to |
73
|
|
|
|
|
|
|
those having the part after C<refs/> in their name equal to it (up to |
74
|
|
|
|
|
|
|
the next C</>). |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
For example, given the following refs: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
HEAD |
79
|
|
|
|
|
|
|
refs/heads/master |
80
|
|
|
|
|
|
|
refs/remotes/origin/HEAD |
81
|
|
|
|
|
|
|
refs/remotes/origin/master |
82
|
|
|
|
|
|
|
refs/tags/world |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
C<ref_names('heads')> will return C<refs/heads/master>, |
85
|
|
|
|
|
|
|
C<ref_names('head')> will return nothing, |
86
|
|
|
|
|
|
|
C<ref_names('remotes/origin')> will return C<refs/remotes/origin/HEAD> |
87
|
|
|
|
|
|
|
and C<refs/remotes/origin/master>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 ref_digest |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$backend->ref_digest('refs/heads/master'); # some SHA-1 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$backend->ref_digest('master'); # undef |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Return the digest of the given reference, or C<undef>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Note that a fully qualified refname is required. This method does not |
98
|
|
|
|
|
|
|
perform any disambiguation. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Philippe Bruhat (BooK) <book@cpan.org>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright 2016 Philippe Bruhat (BooK), all rights reserved. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 LICENSE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
111
|
|
|
|
|
|
|
under the same terms as Perl itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |