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   9234600 use Moose;
  3         12  
  3         24  
4             extends 'Dist::Zilla::PluginBundle::Starter';
5 3     3   20314 use namespace::clean;
  3         8  
  3         39  
6              
7             our $VERSION = 'v5.0.1';
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 760 sub gather_plugin { 'Git::GatherDir' }
20              
21             my @allow_dirty = qw(dist.ini Changes);
22              
23             sub pluginset_release_management {
24 3     3 0 4239 my ($self) = @_;
25 3         119 my $versions = $self->managed_versions;
26 3         222 my @copy_files = @{$self->regenerate};
  3         93  
27 3         31 my @plugins;
28 3         17 push @plugins, ['Git::Check' => {allow_dirty => [@allow_dirty]}];
29 3 50       34 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         73 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       25 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         17 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             In addition to the standard C<[@Starter]> behavior, this bundle restricts the
80             gathered files to those committed to the git repository, allowing F<.gitignore>
81             to also ignore files when assembling the distribution; and commits, tags, and
82             pushes after a successful release.
83              
84             See the L<Dist::Zilla::Starter> guide and the base
85             L<[@Starter]|Dist::Zilla::PluginBundle::Starter> documentation for more
86             information, as this documentation only details the specifics of this subclass.
87              
88             For one-line initialization of a new C<[@Starter::Git]>-based distribution, try
89             L<Dist::Zilla::MintingProfile::Starter::Git>.
90              
91             =head1 OPTIONS
92              
93             C<[@Starter::Git]> inherits the options from
94             L<[@Starter]|Dist::Zilla::PluginBundle::Starter>, and can similarly be further
95             configured by the composed roles, as in L</"CONFIGURING">.
96              
97             =head2 revision
98              
99             [@Starter::Git]
100             revision = 5
101              
102             As in L<Dist::Zilla::PluginBundle::Starter/"revision">, but defaults to
103             revision 3. C<[@Starter::Git]> requires at least revision 3.
104              
105             =head2 installer
106              
107             As in L<Dist::Zilla::PluginBundle::Starter/"installer">.
108              
109             =head2 managed_versions
110              
111             As in L<Dist::Zilla::PluginBundle::Starter/"managed_versions">, and
112             additionally uses L<[Git::Commit]|Dist::Zilla::Plugin::Git::Commit> a second
113             time after L<[BumpVersionAfterRelease]|Dist::Zilla::Plugin::BumpVersionAfterRelease>
114             to commit the bumped versions (with the plugin name C<Version_Bump_Commit>).
115              
116             =head2 regenerate
117              
118             As in L<Dist::Zilla::PluginBundle::Starter/"regenerate">, and allows changes to
119             the copied files to be committed in the C<Release_Commit>.
120              
121             =head1 REVISIONS
122              
123             The C<[@Starter::Git]> plugin bundle supports the following revisions.
124              
125             =head2 Revision 3
126              
127             Revision 3 is the default and is equivalent to using the following plugins:
128              
129             =over 2
130              
131             =item L<[Git::GatherDir]|Dist::Zilla::Plugin::Git::GatherDir>
132              
133             =item L<[MetaYAML]|Dist::Zilla::Plugin::MetaYAML>
134              
135             =item L<[MetaJSON]|Dist::Zilla::Plugin::MetaJSON>
136              
137             =item L<[License]|Dist::Zilla::Plugin::License>
138              
139             =item L<[Pod2Readme]|Dist::Zilla::Plugin::Pod2Readme>
140              
141             =item L<[PodSyntaxTests]|Dist::Zilla::Plugin::PodSyntaxTests>
142              
143             =item L<[Test::ReportPrereqs]|Dist::Zilla::Plugin::Test::ReportPrereqs>
144              
145             =item L<[Test::Compile]|Dist::Zilla::Plugin::Test::Compile>
146              
147             xt_mode = 1
148              
149             =item L<[MakeMaker]|Dist::Zilla::Plugin::MakeMaker>
150              
151             =item L<[Manifest]|Dist::Zilla::Plugin::Manifest>
152              
153             =item L<[PruneCruft]|Dist::Zilla::Plugin::PruneCruft>
154              
155             =item L<[ManifestSkip]|Dist::Zilla::Plugin::ManifestSkip>
156              
157             =item L<[RunExtraTests]|Dist::Zilla::Plugin::RunExtraTests>
158              
159             =item L<[Git::Check]|Dist::Zilla::Plugin::Git::Check>
160              
161             allow_dirty = dist.ini
162             allow_dirty = Changes
163              
164             =item L<[TestRelease]|Dist::Zilla::Plugin::TestRelease>
165              
166             =item L<[ConfirmRelease]|Dist::Zilla::Plugin::ConfirmRelease>
167              
168             =item L<[UploadToCPAN]|Dist::Zilla::Plugin::UploadToCPAN>
169              
170             =item L<[Git::Commit E<sol> Release_Commit]|Dist::Zilla::Plugin::Git::Commit>
171              
172             allow_dirty = dist.ini
173             allow_dirty = Changes
174             add_files_in = /
175             commit_msg = %v%n%n%c
176              
177             =item L<[Git::Tag]|Dist::Zilla::Plugin::Git::Tag>
178              
179             tag_format = %v
180             tag_message = %v
181              
182             =item L<[Git::Push]|Dist::Zilla::Plugin::Git::Push>
183              
184             =item L<[MetaConfig]|Dist::Zilla::Plugin::MetaConfig>
185              
186             =item L<[MetaNoIndex]|Dist::Zilla::Plugin::MetaNoIndex>
187              
188             directory = t
189             directory = xt
190             directory = inc
191             directory = share
192             directory = eg
193             directory = examples
194              
195             =item L<[MetaProvides::Package]|Dist::Zilla::Plugin::MetaProvides::Package>
196              
197             inherit_version = 0
198              
199             =item L<[ShareDir]|Dist::Zilla::Plugin::ShareDir>
200              
201             =item L<[ExecDir]|Dist::Zilla::Plugin::ExecDir>
202              
203             =back
204              
205             This revision differs from L<Revision 3 in [@Starter]|Dist::Zilla::PluginBundle::Starter/"Revision 3">
206             as follows:
207              
208             =over 2
209              
210             =item *
211              
212             Uses L<[Git::GatherDir]|Dist::Zilla::Plugin::Git::GatherDir>
213             instead of L<[GatherDir]|Dist::Zilla::Plugin::GatherDir>.
214              
215             =item *
216              
217             Includes the following additional plugins:
218             L<[Git::Check]|Dist::Zilla::Plugin::Git::Check>,
219             L<[Git::Commit]|Dist::Zilla::Plugin::Git::Commit>,
220             L<[Git::Tag]|Dist::Zilla::Plugin::Git::Tag>,
221             L<[Git::Push]|Dist::Zilla::Plugin::Git::Push>.
222              
223             =back
224              
225             =head2 Revision 4
226              
227             Revision 4 has no specific differences beyond the changes in
228             L<Revision 4 in [@Starter]|Dist::Zilla::PluginBundle::Starter/"Revision 4">.
229              
230             =head2 Revision 5
231              
232             Revision 5 has no specific differences beyond the changes in
233             L<Revision 5 in [@Starter]|Dist::Zilla::PluginBundle::Starter/"Revision 5">.
234              
235             =head1 BUGS
236              
237             Report any issues on the public bugtracker.
238              
239             =head1 AUTHOR
240              
241             Dan Book <dbook@cpan.org>
242              
243             =head1 COPYRIGHT AND LICENSE
244              
245             This software is Copyright (c) 2018 by Dan Book.
246              
247             This is free software, licensed under:
248              
249             The Artistic License 2.0 (GPL Compatible)
250              
251             =head1 SEE ALSO
252              
253             L<Dist::Zilla>, L<Dist::Zilla::PluginBundle::Starter>, L<Dist::Milla>,
254             L<Dist::Zilla::MintingProfile::Starter::Git>