line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Database::Object::Tag; |
2
|
|
|
|
|
|
|
$Git::Database::Object::Tag::VERSION = '0.011'; |
3
|
7
|
|
|
7
|
|
4248
|
use Git::Database::Actor; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
240
|
|
4
|
7
|
|
|
7
|
|
42
|
use DateTime; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
153
|
|
5
|
7
|
|
|
7
|
|
37
|
use Encode qw( decode ); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
350
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
50
|
use Moo; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
39
|
|
8
|
7
|
|
|
7
|
|
2722
|
use namespace::clean; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
59
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Git::Database::Role::Object'; |
11
|
|
|
|
|
|
|
|
12
|
208
|
|
|
208
|
1
|
44159
|
sub kind {'tag'} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has tag_info => ( |
15
|
|
|
|
|
|
|
is => 'rwp', |
16
|
|
|
|
|
|
|
required => 0, |
17
|
|
|
|
|
|
|
predicate => 1, |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
builder => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub BUILD { |
23
|
119
|
|
|
119
|
0
|
69681
|
my ($self) = @_; |
24
|
119
|
100
|
100
|
|
|
3888
|
die "One of 'digest' or 'content' or 'tag_info' is required" |
25
|
|
|
|
|
|
|
if !$self->has_digest && !$self->has_content && !$self->has_tag_info; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
for my $attr ( |
29
|
|
|
|
|
|
|
qw( |
30
|
|
|
|
|
|
|
object |
31
|
|
|
|
|
|
|
type |
32
|
|
|
|
|
|
|
tag |
33
|
|
|
|
|
|
|
tagger |
34
|
|
|
|
|
|
|
tagger_date |
35
|
|
|
|
|
|
|
comment |
36
|
|
|
|
|
|
|
) |
37
|
|
|
|
|
|
|
) |
38
|
|
|
|
|
|
|
{ |
39
|
7
|
|
|
7
|
|
2883
|
no strict 'refs'; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
4799
|
|
40
|
112
|
|
|
112
|
|
3167
|
*$attr = sub { $_[0]->tag_info->{$attr} }; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _build_tag_info { |
44
|
59
|
|
|
59
|
|
13068
|
my ($self) = @_; |
45
|
|
|
|
|
|
|
|
46
|
59
|
100
|
|
|
|
426
|
if ( !$self->has_content ) { |
47
|
14
|
|
|
|
|
78
|
my $attr = $self->_get_object_attributes(); |
48
|
7
|
50
|
|
|
|
43
|
return $attr->{tag_info} if exists $attr->{tag_info}; |
49
|
|
|
|
|
|
|
|
50
|
7
|
50
|
|
|
|
36
|
if ( exists $attr->{content} ) { |
51
|
7
|
|
|
|
|
82
|
$self->_set_content( $attr->{content} ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
0
|
|
|
|
|
0
|
die "Can't build content from these attributes: " |
55
|
|
|
|
|
|
|
. join( ', ', sort keys %$attr ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
52
|
|
|
|
|
192
|
my $tag_info = {}; |
60
|
52
|
|
|
|
|
1242
|
my @lines = split "\n", $self->content; |
61
|
52
|
|
|
|
|
1029
|
while ( my $line = shift @lines ) { |
62
|
208
|
|
|
|
|
797
|
my ( $key, $value ) = split ' ', $line, 2; |
63
|
|
|
|
|
|
|
|
64
|
208
|
100
|
|
|
|
717
|
if ( $key eq 'tagger' ) { |
65
|
52
|
|
|
|
|
387
|
my @data = split ' ', $value; |
66
|
52
|
|
|
|
|
344
|
my ( $email, $epoch, $tz ) = splice( @data, -3 ); |
67
|
52
|
|
|
|
|
2364
|
$tag_info->{tagger} = Git::Database::Actor->new( |
68
|
|
|
|
|
|
|
name => join( ' ', @data ), |
69
|
|
|
|
|
|
|
email => substr( $email, 1, -1 ) |
70
|
|
|
|
|
|
|
); |
71
|
52
|
|
|
|
|
3240
|
$tag_info->{tagger_date} = DateTime->from_epoch( |
72
|
|
|
|
|
|
|
epoch => $epoch, |
73
|
|
|
|
|
|
|
time_zone => $tz |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
156
|
|
|
|
|
1056
|
$tag_info->{$key} = $value; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
52
|
|
|
|
|
68318
|
$tag_info->{comment} = join "\n", @lines; |
81
|
52
|
|
|
|
|
704
|
return $tag_info; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _build_content { |
85
|
51
|
|
|
51
|
|
892
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
51
|
100
|
|
|
|
296
|
if ( ! $self->has_tag_info ) { |
88
|
35
|
|
|
|
|
247
|
my $attr = $self->_get_object_attributes(); |
89
|
21
|
50
|
|
|
|
581
|
return $attr->{content} if exists $attr->{content}; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
0
|
if ( exists $attr->{tag_info} ) { |
92
|
0
|
|
|
|
|
0
|
$self->_set_tag_info( $attr->{tag_info} ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
else { |
95
|
0
|
|
|
|
|
0
|
die "Can't build content from these attributes: " |
96
|
|
|
|
|
|
|
. join( ', ', sort keys %$attr ); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
16
|
|
|
|
|
62
|
my $content; |
101
|
16
|
|
|
|
|
201
|
$content .= "$_ " . $self->$_ . "\n" for qw( object type tag ); |
102
|
16
|
|
|
|
|
275
|
$content .= join( |
103
|
|
|
|
|
|
|
' ', |
104
|
|
|
|
|
|
|
tagger => $self->tagger->ident, |
105
|
|
|
|
|
|
|
$self->tagger_date->epoch, |
106
|
|
|
|
|
|
|
DateTime::TimeZone->offset_as_string( $self->tagger_date->offset ) |
107
|
|
|
|
|
|
|
) . "\n"; |
108
|
16
|
|
|
|
|
2522
|
$content .= "\n"; |
109
|
16
|
|
|
|
|
145
|
my $comment = $self->comment; |
110
|
16
|
|
|
|
|
231
|
chomp $comment; |
111
|
16
|
|
|
|
|
92
|
$content .= "$comment\n"; |
112
|
|
|
|
|
|
|
|
113
|
16
|
|
|
|
|
470
|
return $content; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=pod |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=for Pod::Coverage |
123
|
|
|
|
|
|
|
BUILD |
124
|
|
|
|
|
|
|
has_tag_info |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 NAME |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Git::Database::Object::Tag - A tag object in the Git database |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 VERSION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
version 0.011 |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SYNOPSIS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my $r = Git::Database->new(); # current Git repository |
137
|
|
|
|
|
|
|
my $tag = $r->get_object('f5c10c'); # abbreviated digest |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# attributes |
140
|
|
|
|
|
|
|
$tag->kind; # tag |
141
|
|
|
|
|
|
|
$tag->digest; # f5c10c1a841419d3b1db0c3e0c42b554f9e1eeb2 |
142
|
|
|
|
|
|
|
$tag->object; # ef25e81ba86b7df16956c974c8a9c1ff2eca1326 |
143
|
|
|
|
|
|
|
$tag->type; # commit |
144
|
|
|
|
|
|
|
...; # etc., see below |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 DESCRIPTION |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Git::Database::Object::Tag represents a C<tag> object |
149
|
|
|
|
|
|
|
obtained via L<Git::Database> from a Git object database. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
All major attributes (L</digest>, L</content>, L</size>, L</tag_info>) |
154
|
|
|
|
|
|
|
have a predicate method. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 kind |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The object kind: C<tag> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 digest |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
The SHA-1 digest of the digest object. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 content |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The object's actual content. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 size |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
The size (in bytes) of the object content. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 tag_info |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
A hash reference containing the all the attributes listed below, as |
175
|
|
|
|
|
|
|
values for the keys with the same names. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 object |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
The SHA-1 digest of the tagged object. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 type |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
The type of the tagged object. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 tag |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
The tag name. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 tagger |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
A L<Git::Database::Actor> object representing the author of |
192
|
|
|
|
|
|
|
the tag. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 tagger_date |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
A L<DateTime> object representing the date at which the author |
197
|
|
|
|
|
|
|
created the tag. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 comment |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
The text of the tag. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 METHODS |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 new() |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Create a new Git::Object::Database::Tag object. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
One (and only one) of the C<content> or C<tag> arguments is |
210
|
|
|
|
|
|
|
required. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
C<tag_info> is a reference to a hash containing the keys listed |
213
|
|
|
|
|
|
|
above, i.e. C<object>, C<type>, C<tag>, C<tagger>, C<tagger_time>, |
214
|
|
|
|
|
|
|
and C<comment>. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 SEE ALSO |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L<Git::Database>, |
219
|
|
|
|
|
|
|
L<Git::Database::Role::Object>. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 AUTHOR |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Philippe Bruhat (BooK) <book@cpan.org>. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 COPYRIGHT |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Copyright 2013-2016 Philippe Bruhat (BooK), all rights reserved. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 LICENSE |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
232
|
|
|
|
|
|
|
under the same terms as Perl itself. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=cut |