| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Git::Describe; |
|
2
|
|
|
|
|
|
|
# git description: 0.005-1-gecec158 |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: add the results of `git describe` (roughly) to your main module |
|
5
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::Git::Describe::VERSION = '0.006'; |
|
6
|
3
|
|
|
3
|
|
2577547
|
use Moose; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
27
|
|
|
7
|
|
|
|
|
|
|
with( |
|
8
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileMunger', |
|
9
|
|
|
|
|
|
|
'Dist::Zilla::Role::PPI', |
|
10
|
|
|
|
|
|
|
); |
|
11
|
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
20447
|
use Git::Wrapper; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
90
|
|
|
13
|
3
|
|
|
3
|
|
15
|
use Try::Tiny; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
271
|
|
|
14
|
3
|
|
|
3
|
|
19
|
use List::Util 1.33 'all'; |
|
|
3
|
|
|
|
|
85
|
|
|
|
3
|
|
|
|
|
217
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
22
|
use namespace::autoclean; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
#pod |
|
20
|
|
|
|
|
|
|
#pod in dist.ini |
|
21
|
|
|
|
|
|
|
#pod |
|
22
|
|
|
|
|
|
|
#pod [Git::Describe] |
|
23
|
|
|
|
|
|
|
#pod |
|
24
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod This plugin will add the long-form git commit description for the current repo |
|
27
|
|
|
|
|
|
|
#pod to the dist's main module as a comment. It may change, in the future, to put |
|
28
|
|
|
|
|
|
|
#pod things in a package variable, or to provide an option. |
|
29
|
|
|
|
|
|
|
#pod |
|
30
|
|
|
|
|
|
|
#pod It inserts this in the same place that PkgVersion would insert a version. |
|
31
|
|
|
|
|
|
|
#pod |
|
32
|
|
|
|
|
|
|
#pod =attr on_package_line |
|
33
|
|
|
|
|
|
|
#pod |
|
34
|
|
|
|
|
|
|
#pod If true, then the comment is added to the same line as the package declaration. |
|
35
|
|
|
|
|
|
|
#pod Otherwise, it is added on its own line, with an additional blank line following it. |
|
36
|
|
|
|
|
|
|
#pod Defaults to false. |
|
37
|
|
|
|
|
|
|
#pod |
|
38
|
|
|
|
|
|
|
#pod =cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has on_package_line => ( |
|
41
|
|
|
|
|
|
|
is => 'ro', |
|
42
|
|
|
|
|
|
|
isa => 'Bool', |
|
43
|
|
|
|
|
|
|
default => 0, |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub munge_files { |
|
47
|
3
|
|
|
3
|
0
|
690279
|
my ($self) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
157
|
my $file = $self->zilla->main_module; |
|
50
|
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
11410
|
require PPI::Document; |
|
52
|
3
|
|
|
|
|
407461
|
my $document = $self->ppi_document_for_file($file); |
|
53
|
|
|
|
|
|
|
|
|
54
|
3
|
50
|
|
|
|
10057
|
return unless my $package_stmts = $document->find('PPI::Statement::Package'); |
|
55
|
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
2265
|
my $git = Git::Wrapper->new( $self->zilla->root ); |
|
57
|
3
|
|
|
|
|
436
|
my @lines = $git->describe({ long => 1, always => 1 }); |
|
58
|
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
30369
|
my $desc = $lines[0]; |
|
60
|
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
14
|
my %seen_pkg; |
|
62
|
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
20
|
for my $stmt (@$package_stmts) { |
|
64
|
3
|
|
|
|
|
93
|
my $package = $stmt->namespace; |
|
65
|
|
|
|
|
|
|
|
|
66
|
3
|
50
|
|
|
|
287
|
if ($seen_pkg{ $package }++) { |
|
67
|
0
|
|
|
|
|
0
|
$self->log([ 'skipping package re-declaration for %s', $package ]); |
|
68
|
0
|
|
|
|
|
0
|
next; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
3
|
50
|
|
|
|
32
|
if ($stmt->content =~ /package\s*(?:#.*)?\n\s*\Q$package/) { |
|
72
|
0
|
|
|
|
|
0
|
$self->log([ 'skipping private package %s in %s', $package, $file->name ]); |
|
73
|
0
|
|
|
|
|
0
|
next; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
3
|
100
|
|
|
|
472
|
my $perl = $self->on_package_line |
|
77
|
|
|
|
|
|
|
? " # git description: $desc" |
|
78
|
|
|
|
|
|
|
: "\n# git description: $desc\n"; |
|
79
|
|
|
|
|
|
|
|
|
80
|
3
|
|
|
|
|
64
|
my $version_doc = PPI::Document->new(\$perl); |
|
81
|
3
|
|
|
|
|
2286
|
my @children = $version_doc->children; |
|
82
|
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
71
|
$self->log_debug([ |
|
84
|
|
|
|
|
|
|
'adding git description comment to %s in %s', |
|
85
|
|
|
|
|
|
|
$package, |
|
86
|
|
|
|
|
|
|
$file->name, |
|
87
|
|
|
|
|
|
|
]); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Carp::carp("error inserting git description in " . $file->name) |
|
90
|
3
|
50
|
|
5
|
|
3408
|
unless all { $stmt->insert_after($_->clone) } reverse @children; |
|
|
5
|
|
|
|
|
302
|
|
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
3
|
|
|
|
|
486
|
$self->save_ppi_document_to_file($document, $file); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
97
|
|
|
|
|
|
|
1; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=pod |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=encoding UTF-8 |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Git::Describe - add the results of `git describe` (roughly) to your main module |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 VERSION |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
version 0.006 |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
in dist.ini |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
[Git::Describe] |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This plugin will add the long-form git commit description for the current repo |
|
120
|
|
|
|
|
|
|
to the dist's main module as a comment. It may change, in the future, to put |
|
121
|
|
|
|
|
|
|
things in a package variable, or to provide an option. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
It inserts this in the same place that PkgVersion would insert a version. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 on_package_line |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
If true, then the comment is added to the same line as the package declaration. |
|
130
|
|
|
|
|
|
|
Otherwise, it is added on its own line, with an additional blank line following it. |
|
131
|
|
|
|
|
|
|
Defaults to false. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L<PodVersion|Dist::Zilla::Plugin::PkgVersion> |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Ricardo Signes <rjbs@cpan.org> |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=for stopwords Karen Etheridge |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Ricardo Signes. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
152
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
__END__ |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
159
|
|
|
|
|
|
|
#pod |
|
160
|
|
|
|
|
|
|
#pod L<PodVersion|Dist::Zilla::Plugin::PkgVersion> |
|
161
|
|
|
|
|
|
|
#pod |
|
162
|
|
|
|
|
|
|
#pod =cut |