| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Git::Database::Object::Tag; |
|
2
|
|
|
|
|
|
|
$Git::Database::Object::Tag::VERSION = '0.012'; |
|
3
|
8
|
|
|
8
|
|
4839
|
use Git::Database::Actor; |
|
|
8
|
|
|
|
|
20
|
|
|
|
8
|
|
|
|
|
271
|
|
|
4
|
8
|
|
|
8
|
|
48
|
use DateTime; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
168
|
|
|
5
|
8
|
|
|
8
|
|
38
|
use Encode qw( decode ); |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
363
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
56
|
use Moo; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
52
|
|
|
8
|
8
|
|
|
8
|
|
2627
|
use namespace::clean; |
|
|
8
|
|
|
|
|
20
|
|
|
|
8
|
|
|
|
|
58
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Git::Database::Role::Object'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
208
|
|
|
208
|
1
|
38833
|
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
|
63272
|
my ($self) = @_; |
|
24
|
119
|
100
|
100
|
|
|
3524
|
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
|
8
|
|
|
8
|
|
3122
|
no strict 'refs'; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
5103
|
|
|
40
|
112
|
|
|
112
|
|
2812
|
*$attr = sub { $_[0]->tag_info->{$attr} }; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _build_tag_info { |
|
44
|
59
|
|
|
59
|
|
14013
|
my ($self) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
59
|
100
|
|
|
|
422
|
if ( !$self->has_content ) { |
|
47
|
14
|
|
|
|
|
81
|
my $attr = $self->_get_object_attributes(); |
|
48
|
7
|
50
|
|
|
|
45
|
return $attr->{tag_info} if exists $attr->{tag_info}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
7
|
50
|
|
|
|
48
|
if ( exists $attr->{content} ) { |
|
51
|
7
|
|
|
|
|
62
|
$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
|
|
|
|
|
148
|
my $tag_info = {}; |
|
60
|
52
|
|
|
|
|
1282
|
my @lines = split "\n", $self->content; |
|
61
|
52
|
|
|
|
|
1119
|
while ( my $line = shift @lines ) { |
|
62
|
208
|
|
|
|
|
770
|
my ( $key, $value ) = split ' ', $line, 2; |
|
63
|
|
|
|
|
|
|
|
|
64
|
208
|
100
|
|
|
|
588
|
if ( $key eq 'tagger' ) { |
|
65
|
52
|
|
|
|
|
313
|
my @data = split ' ', $value; |
|
66
|
52
|
|
|
|
|
382
|
my ( $email, $epoch, $tz ) = splice( @data, -3 ); |
|
67
|
52
|
|
|
|
|
2079
|
$tag_info->{tagger} = Git::Database::Actor->new( |
|
68
|
|
|
|
|
|
|
name => join( ' ', @data ), |
|
69
|
|
|
|
|
|
|
email => substr( $email, 1, -1 ) |
|
70
|
|
|
|
|
|
|
); |
|
71
|
52
|
|
|
|
|
3076
|
$tag_info->{tagger_date} = DateTime->from_epoch( |
|
72
|
|
|
|
|
|
|
epoch => $epoch, |
|
73
|
|
|
|
|
|
|
time_zone => $tz |
|
74
|
|
|
|
|
|
|
); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
else { |
|
77
|
156
|
|
|
|
|
819
|
$tag_info->{$key} = $value; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
52
|
|
|
|
|
62293
|
$tag_info->{comment} = join "\n", @lines; |
|
81
|
52
|
|
|
|
|
716
|
return $tag_info; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _build_content { |
|
85
|
51
|
|
|
51
|
|
888
|
my ($self) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
51
|
100
|
|
|
|
285
|
if ( ! $self->has_tag_info ) { |
|
88
|
35
|
|
|
|
|
255
|
my $attr = $self->_get_object_attributes(); |
|
89
|
21
|
50
|
|
|
|
606
|
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
|
|
|
|
|
41
|
my $content; |
|
101
|
16
|
|
|
|
|
148
|
$content .= "$_ " . $self->$_ . "\n" for qw( object type tag ); |
|
102
|
16
|
|
|
|
|
240
|
$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
|
|
|
|
|
2452
|
$content .= "\n"; |
|
109
|
16
|
|
|
|
|
81
|
my $comment = $self->comment; |
|
110
|
16
|
|
|
|
|
244
|
chomp $comment; |
|
111
|
16
|
|
|
|
|
64
|
$content .= "$comment\n"; |
|
112
|
|
|
|
|
|
|
|
|
113
|
16
|
|
|
|
|
457
|
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.012 |
|
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 |