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