File Coverage

blib/lib/Minilla/Release/CheckChanges.pm
Criterion Covered Total %
statement 18 34 52.9
branch 0 12 0.0
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 24 54 44.4


line stmt bran cond sub pod time code
1             package Minilla::Release::CheckChanges;
2 1     1   972 use strict;
  1         2  
  1         30  
3 1     1   5 use warnings;
  1         2  
  1         21  
4 1     1   6 use utf8;
  1         2  
  1         5  
5 1     1   25 use ExtUtils::MakeMaker qw(prompt);
  1         2  
  1         60  
6              
7 1     1   7 use Minilla::Util qw(edit_file slurp);
  1         2  
  1         40  
8 1     1   5 use Minilla::Logger;
  1         2  
  1         366  
9              
10             sub run {
11 0     0 0   my ($self, $project, $opts) = @_;
12              
13 0           my $version = $project->version;
14              
15 0 0         if ($ENV{PERL_MINILLA_SKIP_CHECK_CHANGE_LOG}) {
16 0           infof("Okay, you are debugging now.\n");
17 0           return;
18             }
19              
20 0           while (1) {
21 0           my $changes = slurp('Changes');
22 0 0         last if $changes =~ /^\{\{\$NEXT\}\}\h*\R+\h+\S/m;
23              
24             # Tell the user what the problem is
25 0 0         if ($changes !~ /\{\{\$NEXT\}\}/m) {
    0          
    0          
26 0           infof("No mention of {{\$NEXT}} in changelog file 'Changes'\n");
27             } elsif ($changes !~ /^\{\{\$NEXT\}\}/m) {
28 0           infof("{{\$NEXT}} must be at the beginning of a line in changelog file 'Changes'\n");
29             } elsif ($changes !~ /^\{\{\$NEXT\}\}\h*\R/m) {
30 0           infof("{{\$NEXT}} in changelog file 'Changes' must be the only non-whitespace on its line\n");
31             } else {
32 0           infof("{{\$NEXT}} in changelog file 'Changes' must be followed by at least one indented line describing a change\n");
33             }
34              
35 0 0         if (prompt("Edit file?", 'y') =~ /y/i) {
36 0           edit_file('Changes');
37             } else {
38 0           errorf("Giving up!\n");
39             }
40             }
41             }
42              
43             1;