File Coverage

blib/lib/Dist/Zilla/PluginBundle/Starter/Git.pm
Criterion Covered Total %
statement 19 19 100.0
branch 3 6 50.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 26 31 83.8


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::Starter::Git;
2              
3 3     3   9556467 use Moose;
  3         11  
  3         25  
4             extends 'Dist::Zilla::PluginBundle::Starter';
5 3     3   22234 use namespace::clean;
  3         11  
  3         35  
6              
7             our $VERSION = 'v5.0.0';
8              
9             has '+revision' => (
10             default => sub { $_[0]->payload->{revision} // 3 },
11             );
12              
13             before configure => sub {
14             my ($self) = @_;
15             my $name = $self->name;
16             die "[$name] requires at least revision 3\n" unless $self->revision >= 3;
17             };
18              
19 3     3 0 831 sub gather_plugin { 'Git::GatherDir' }
20              
21             my @allow_dirty = qw(dist.ini Changes);
22              
23             sub pluginset_release_management {
24 3     3 0 4657 my ($self) = @_;
25 3         111 my $versions = $self->managed_versions;
26 3         245 my @copy_files = @{$self->regenerate};
  3         89  
27 3         33 my @plugins;
28 3         16 push @plugins, ['Git::Check' => {allow_dirty => [@allow_dirty]}];
29 3 50       42 push @plugins, 'RewriteVersion',
30             [NextRelease => { format => '%-9v %{yyyy-MM-dd HH:mm:ss VVV}d%{ (TRIAL RELEASE)}T' }]
31             if $versions;
32 3 50       127 push @plugins,
33             [CopyFilesFromRelease => { filename => [@copy_files] }],
34             ['Regenerate::AfterReleasers' => { plugin => $self->name . '/CopyFilesFromRelease' }],
35             if @copy_files;
36 3         96 push @plugins,
37             ['Git::Commit' => 'Release_Commit' => { allow_dirty => [@allow_dirty, @copy_files], add_files_in => '/', commit_msg => '%v%n%n%c' }],
38             ['Git::Tag' => { tag_format => '%v', tag_message => '%v' }];
39 3 50       26 push @plugins, 'BumpVersionAfterRelease',
40             ['Git::Commit' => 'Version_Bump_Commit' => { allow_dirty_match => '^', commit_msg => 'Bump version' }]
41             if $versions;
42 3         9 push @plugins, 'Git::Push';
43 3         20 return @plugins;
44             }
45              
46             __PACKAGE__->meta->make_immutable;
47             1;
48              
49             =head1 NAME
50              
51             Dist::Zilla::PluginBundle::Starter::Git - A minimal Dist::Zilla plugin bundle for git workflows
52              
53             =head1 SYNOPSIS
54              
55             ; dist.ini
56             name = My-Cool-Distribution
57             author = Example Jones <jones@example.com>
58             license = Perl_5
59             copyright_holder = Example Jones
60             copyright_year = 2017
61             version = 0.001
62            
63             [@Starter::Git] ; all that is needed to start
64             revision = 5 ; always defaults to revision 3
65            
66             ; configuring examples
67             installer = ModuleBuildTiny
68             -remove = Pod2Readme ; to use [Readme::Brief] instead, for example
69             ExecDir.dir = script ; change the directory used by [ExecDir]
70             managed_versions = 1 ; uses the main module version, and bumps module versions after release
71             regenerate = LICENSE ; copy LICENSE to repository after release or dzil regenerate
72              
73             =head1 DESCRIPTION
74              
75             The C<[@Starter::Git]> plugin bundle for L<Dist::Zilla> is a subclass of the
76             L<[@Starter]|Dist::Zilla::PluginBundle::Starter> plugin bundle designed to
77             support a Git-based workflow.
78              
79             See the L<Dist::Zilla::Starter> guide and the base
80             L<[@Starter]|Dist::Zilla::PluginBundle::Starter> documentation, as this
81             documentation only details the specifics of this subclass.
82              
83             For one-line initialization of a new C<[@Starter::Git]>-based distribution, try
84             L<Dist::Zilla::MintingProfile::Starter::Git>.
85              
86             =head1 OPTIONS
87              
88             C<[@Starter::Git]> inherits the options from
89             L<[@Starter]|Dist::Zilla::PluginBundle::Starter>, and can similarly be further
90             configured by the composed roles, as in L</"CONFIGURING">.
91              
92             =head2 revision
93              
94             [@Starter::Git]
95             revision = 5
96              
97             As in L<Dist::Zilla::PluginBundle::Starter/"revision">, but defaults to
98             revision 3. C<[@Starter::Git]> requires at least revision 3.
99              
100             =head2 installer
101              
102             As in L<Dist::Zilla::PluginBundle::Starter/"installer">.
103              
104             =head2 managed_versions
105              
106             As in L<Dist::Zilla::PluginBundle::Starter/"managed_versions">, and
107             additionally uses L<[Git::Commit]|Dist::Zilla::Plugin::Git::Commit> a second
108             time after L<[BumpVersionAfterRelease]|Dist::Zilla::Plugin::BumpVersionAfterRelease>
109             to commit the bumped versions (with the plugin name C<Version_Bump_Commit>).
110              
111             =head2 regenerate
112              
113             As in L<Dist::Zilla::PluginBundle::Starter/"regenerate">, and allows changes to
114             the copied files to be committed in the C<Release_Commit>.
115              
116             =head1 REVISIONS
117              
118             The C<[@Starter::Git]> plugin bundle supports the following revisions.
119              
120             =head2 Revision 3
121              
122             Revision 3 is the default and is equivalent to using the following plugins:
123              
124             =over 2
125              
126             =item L<[Git::GatherDir]|Dist::Zilla::Plugin::Git::GatherDir>
127              
128             =item L<[MetaYAML]|Dist::Zilla::Plugin::MetaYAML>
129              
130             =item L<[MetaJSON]|Dist::Zilla::Plugin::MetaJSON>
131              
132             =item L<[License]|Dist::Zilla::Plugin::License>
133              
134             =item L<[Pod2Readme]|Dist::Zilla::Plugin::Pod2Readme>
135              
136             =item L<[PodSyntaxTests]|Dist::Zilla::Plugin::PodSyntaxTests>
137              
138             =item L<[Test::ReportPrereqs]|Dist::Zilla::Plugin::Test::ReportPrereqs>
139              
140             =item L<[Test::Compile]|Dist::Zilla::Plugin::Test::Compile>
141              
142             xt_mode = 1
143              
144             =item L<[MakeMaker]|Dist::Zilla::Plugin::MakeMaker>
145              
146             =item L<[Manifest]|Dist::Zilla::Plugin::Manifest>
147              
148             =item L<[PruneCruft]|Dist::Zilla::Plugin::PruneCruft>
149              
150             =item L<[ManifestSkip]|Dist::Zilla::Plugin::ManifestSkip>
151              
152             =item L<[RunExtraTests]|Dist::Zilla::Plugin::RunExtraTests>
153              
154             =item L<[Git::Check]|Dist::Zilla::Plugin::Git::Check>
155              
156             allow_dirty = dist.ini
157             allow_dirty = Changes
158              
159             =item L<[TestRelease]|Dist::Zilla::Plugin::TestRelease>
160              
161             =item L<[ConfirmRelease]|Dist::Zilla::Plugin::ConfirmRelease>
162              
163             =item L<[UploadToCPAN]|Dist::Zilla::Plugin::UploadToCPAN>
164              
165             =item L<[Git::Commit E<sol> Release_Commit]|Dist::Zilla::Plugin::Git::Commit>
166              
167             allow_dirty = dist.ini
168             allow_dirty = Changes
169             add_files_in = /
170             commit_msg = %v%n%n%c
171              
172             =item L<[Git::Tag]|Dist::Zilla::Plugin::Git::Tag>
173              
174             tag_format = %v
175             tag_message = %v
176              
177             =item L<[Git::Push]|Dist::Zilla::Plugin::Git::Push>
178              
179             =item L<[MetaConfig]|Dist::Zilla::Plugin::MetaConfig>
180              
181             =item L<[MetaNoIndex]|Dist::Zilla::Plugin::MetaNoIndex>
182              
183             directory = t
184             directory = xt
185             directory = inc
186             directory = share
187             directory = eg
188             directory = examples
189              
190             =item L<[MetaProvides::Package]|Dist::Zilla::Plugin::MetaProvides::Package>
191              
192             inherit_version = 0
193              
194             =item L<[ShareDir]|Dist::Zilla::Plugin::ShareDir>
195              
196             =item L<[ExecDir]|Dist::Zilla::Plugin::ExecDir>
197              
198             =back
199              
200             This revision differs from L<Revision 3 in [@Starter]|Dist::Zilla::PluginBundle::Starter/"Revision 3">
201             as follows:
202              
203             =over 2
204              
205             =item *
206              
207             Uses L<[Git::GatherDir]|Dist::Zilla::Plugin::Git::GatherDir>
208             instead of L<[GatherDir]|Dist::Zilla::Plugin::GatherDir>.
209              
210             =item *
211              
212             Includes the following additional plugins:
213             L<[Git::Check]|Dist::Zilla::Plugin::Git::Check>,
214             L<[Git::Commit]|Dist::Zilla::Plugin::Git::Commit>,
215             L<[Git::Tag]|Dist::Zilla::Plugin::Git::Tag>,
216             L<[Git::Push]|Dist::Zilla::Plugin::Git::Push>.
217              
218             =back
219              
220             =head2 Revision 4
221              
222             Revision 4 has no specific differences beyond the changes in
223             L<Revision 4 in [@Starter]|Dist::Zilla::PluginBundle::Starter/"Revision 4">.
224              
225             =head2 Revision 5
226              
227             Revision 5 has no specific differences beyond the changes in
228             L<Revision 5 in [@Starter]|Dist::Zilla::PluginBundle::Starter/"Revision 5">.
229              
230             =head1 BUGS
231              
232             Report any issues on the public bugtracker.
233              
234             =head1 AUTHOR
235              
236             Dan Book <dbook@cpan.org>
237              
238             =head1 COPYRIGHT AND LICENSE
239              
240             This software is Copyright (c) 2018 by Dan Book.
241              
242             This is free software, licensed under:
243              
244             The Artistic License 2.0 (GPL Compatible)
245              
246             =head1 SEE ALSO
247              
248             L<Dist::Zilla>, L<Dist::Zilla::PluginBundle::Starter>, L<Dist::Milla>,
249             L<Dist::Zilla::MintingProfile::Starter::Git>