| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of Dist-Zilla-Plugin-Git |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This software is copyright (c) 2009 by Jerome Quelin. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
10
|
|
|
10
|
|
17856042
|
use 5.008; |
|
|
10
|
|
|
|
|
59
|
|
|
10
|
10
|
|
|
10
|
|
67
|
use strict; |
|
|
10
|
|
|
|
|
27
|
|
|
|
10
|
|
|
|
|
330
|
|
|
11
|
10
|
|
|
10
|
|
97
|
use warnings; |
|
|
10
|
|
|
|
|
28
|
|
|
|
10
|
|
|
|
|
880
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Git::Commit; |
|
14
|
|
|
|
|
|
|
# ABSTRACT: Commit dirty files |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '2.048'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
10
|
|
|
10
|
|
88
|
use namespace::autoclean; |
|
|
10
|
|
|
|
|
25
|
|
|
|
10
|
|
|
|
|
127
|
|
|
19
|
10
|
|
|
10
|
|
1777
|
use File::Temp qw{ tempfile }; |
|
|
10
|
|
|
|
|
20391
|
|
|
|
10
|
|
|
|
|
1147
|
|
|
20
|
10
|
|
|
10
|
|
86
|
use Moose; |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
94
|
|
|
21
|
10
|
|
|
10
|
|
78008
|
use MooseX::Has::Sugar; |
|
|
10
|
|
|
|
|
8439
|
|
|
|
10
|
|
|
|
|
51
|
|
|
22
|
10
|
|
|
10
|
|
7259
|
use Types::Standard qw(Str ArrayRef Bool); |
|
|
10
|
|
|
|
|
848940
|
|
|
|
10
|
|
|
|
|
138
|
|
|
23
|
10
|
|
|
10
|
|
18185
|
use Types::Path::Tiny 'Path'; |
|
|
10
|
|
|
|
|
251397
|
|
|
|
10
|
|
|
|
|
188
|
|
|
24
|
10
|
|
|
10
|
|
5176
|
use Path::Tiny 0.048 qw(); # subsumes |
|
|
10
|
|
|
|
|
500
|
|
|
|
10
|
|
|
|
|
249
|
|
|
25
|
10
|
|
|
10
|
|
60
|
use Cwd; |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
7874
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::AfterRelease', |
|
28
|
|
|
|
|
|
|
'Dist::Zilla::Role::Git::Repo'; |
|
29
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Git::DirtyFiles'; |
|
30
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Git::StringFormatter'; |
|
31
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::GitConfig'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _git_config_mapping { +{ |
|
34
|
2
|
|
|
2
|
|
337
|
changelog => '%{changelog}s', |
|
35
|
|
|
|
|
|
|
} } |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# -- attributes |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has commit_msg => ( ro, isa=>Str, default => 'v%V%n%n%c' ); |
|
40
|
|
|
|
|
|
|
has add_files_in => ( ro, isa=> ArrayRef[Path], coerce => 1, default => sub { [] }); |
|
41
|
|
|
|
|
|
|
has signoff => ( ro, isa => Bool, default => 0 ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# -- public methods |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub mvp_multivalue_args { qw( add_files_in ) } |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
around dump_config => sub |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
|
|
|
|
|
|
my $orig = shift; |
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $config = $self->$orig; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = { |
|
56
|
|
|
|
|
|
|
commit_msg => $self->commit_msg, |
|
57
|
|
|
|
|
|
|
add_files_in => [ sort @{ $self->add_files_in } ], |
|
58
|
|
|
|
|
|
|
signoff => $self->signoff, |
|
59
|
|
|
|
|
|
|
blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (), |
|
60
|
|
|
|
|
|
|
}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $config; |
|
63
|
|
|
|
|
|
|
}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub after_release { |
|
66
|
9
|
|
|
9
|
0
|
937759
|
my $self = shift; |
|
67
|
|
|
|
|
|
|
|
|
68
|
9
|
|
|
|
|
409
|
my $git = $self->git; |
|
69
|
9
|
|
|
|
|
126
|
my @output; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# check if there are dirty files that need to be committed. |
|
72
|
|
|
|
|
|
|
# at this time, we know that only those 2 files may remain modified, |
|
73
|
|
|
|
|
|
|
# otherwise before_release would have failed, ending the release |
|
74
|
|
|
|
|
|
|
# process. |
|
75
|
9
|
|
|
|
|
329
|
@output = sort { lc $a cmp lc $b } $self->list_dirty_files($git, 1); |
|
|
9
|
|
|
|
|
101496
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# add any other untracked files to the commit list |
|
78
|
9
|
100
|
|
|
|
142
|
if ( @{ $self->add_files_in } ) { |
|
|
9
|
|
|
|
|
1506
|
|
|
79
|
1
|
|
|
|
|
40
|
my @untracked_files = $git->ls_files( { others=>1, 'exclude-standard'=>1 } ); |
|
80
|
1
|
|
|
|
|
9972
|
foreach my $f ( @untracked_files ) { |
|
81
|
1
|
|
|
|
|
13
|
foreach my $path ( @{ $self->add_files_in } ) { |
|
|
1
|
|
|
|
|
175
|
|
|
82
|
1
|
50
|
|
|
|
81
|
if ( Path::Tiny::path( $path )->subsumes( $f ) ) { |
|
83
|
1
|
|
|
|
|
553
|
push( @output, $f ); |
|
84
|
1
|
|
|
|
|
16
|
last; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# if nothing to commit, we're done! |
|
91
|
9
|
50
|
|
|
|
162
|
return unless @output; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# write commit message in a temp file |
|
94
|
9
|
|
|
|
|
912
|
my ($fh, $filename) = tempfile( getcwd . '/DZP-git.XXXX', UNLINK => 1 ); |
|
95
|
9
|
50
|
|
|
|
9059
|
binmode $fh, ':utf8' unless Dist::Zilla->VERSION < 5; |
|
96
|
9
|
|
|
|
|
174
|
print $fh $self->get_commit_message; |
|
97
|
9
|
|
|
|
|
1960
|
close $fh; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# commit the files in git |
|
100
|
9
|
|
|
|
|
291
|
$git->add( @output ); |
|
101
|
9
|
|
|
|
|
110363
|
$self->log_debug($_) for $git->commit( { signoff => $self->signoff, |
|
102
|
|
|
|
|
|
|
file => $filename } ); |
|
103
|
9
|
|
|
|
|
132362
|
$self->log("Committed @output"); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#pod =method get_commit_message |
|
108
|
|
|
|
|
|
|
#pod |
|
109
|
|
|
|
|
|
|
#pod This method returns the commit message. The default implementation |
|
110
|
|
|
|
|
|
|
#pod reads the Changes file to get the list of changes in the just-released version. |
|
111
|
|
|
|
|
|
|
#pod |
|
112
|
|
|
|
|
|
|
#pod =cut |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub get_commit_message { |
|
115
|
19
|
|
|
19
|
1
|
139
|
my $self = shift; |
|
116
|
|
|
|
|
|
|
|
|
117
|
19
|
|
|
|
|
1014
|
return $self->_format_string($self->commit_msg); |
|
118
|
|
|
|
|
|
|
} # end get_commit_message |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=pod |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=encoding UTF-8 |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 NAME |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Git::Commit - Commit dirty files |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 VERSION |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
version 2.048 |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
In your F<dist.ini>: |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
[Git::Commit] |
|
142
|
|
|
|
|
|
|
changelog = Changes ; this is the default |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Once the release is done, this plugin will record this fact in git by |
|
147
|
|
|
|
|
|
|
committing changelog and F<dist.ini>. The commit message will be taken |
|
148
|
|
|
|
|
|
|
from the changelog for this release. It will include lines between |
|
149
|
|
|
|
|
|
|
the current version and timestamp and the next non-indented line, |
|
150
|
|
|
|
|
|
|
except that blank lines at the beginning or end are removed. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
B<Warning:> If you are using Git::Commit in conjunction with the |
|
153
|
|
|
|
|
|
|
L<NextRelease|Dist::Zilla::Plugin::NextRelease> plugin, |
|
154
|
|
|
|
|
|
|
C<[NextRelease]> must come before C<[Git::Commit]> (or C<[@Git]>) in |
|
155
|
|
|
|
|
|
|
your F<dist.ini> or plugin bundle. Otherwise, Git::Commit will commit |
|
156
|
|
|
|
|
|
|
the F<Changes> file before NextRelease has updated it. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The plugin accepts the following options: |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=over 4 |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * changelog - the name of your changelog file. Defaults to F<Changes>. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * allow_dirty - a file that will be checked in if it is locally |
|
165
|
|
|
|
|
|
|
modified. This option may appear multiple times. The default |
|
166
|
|
|
|
|
|
|
list is F<dist.ini> and the changelog file given by C<changelog>. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * allow_dirty_match - works the same as allow_dirty, but |
|
169
|
|
|
|
|
|
|
matching as a regular expression(s) instead of an exact filename(s). |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * add_files_in - a path that will have its new files checked in. |
|
172
|
|
|
|
|
|
|
This option may appear multiple times. This is used to add files |
|
173
|
|
|
|
|
|
|
generated during build-time to the repository, for example. The default |
|
174
|
|
|
|
|
|
|
list is empty. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Note: The files have to be generated between the phases BeforeRelease |
|
177
|
|
|
|
|
|
|
E<lt>-E<gt> AfterRelease, and after Git::Check + before Git::Commit. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * commit_msg - the commit message to use. Defaults to |
|
180
|
|
|
|
|
|
|
C<v%V%n%n%c>, meaning the version number and the list of changes. |
|
181
|
|
|
|
|
|
|
The L<formatting codes|Dist::Zilla::Role::Git::StringFormatter/DESCRIPTION> |
|
182
|
|
|
|
|
|
|
are documented under L<Dist::Zilla::Role::Git::StringFormatter>. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * time_zone - the time zone to use with C<%d>. Can be any |
|
185
|
|
|
|
|
|
|
time zone name accepted by DateTime. Defaults to C<local>. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=back |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 METHODS |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 get_commit_message |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This method returns the commit message. The default implementation |
|
194
|
|
|
|
|
|
|
reads the Changes file to get the list of changes in the just-released version. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=for Pod::Coverage after_release mvp_multivalue_args |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 SUPPORT |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Git> |
|
201
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-Git@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Git@rt.cpan.org>). |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
|
204
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
|
207
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 AUTHOR |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Jerome Quelin |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
This software is copyright (c) 2009 by Jerome Quelin. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
218
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=cut |