File Coverage

blib/lib/ShipIt/Step/CommitMessageWrap.pm
Criterion Covered Total %
statement 21 42 50.0
branch n/a
condition 0 2 0.0
subroutine 7 11 63.6
pod 2 2 100.0
total 30 57 52.6


line stmt bran cond sub pod time code
1             package ShipIt::Step::CommitMessageWrap;
2 1     1   5 use strict;
  1         2  
  1         35  
3 1     1   5 use warnings;
  1         3  
  1         40  
4 1     1   4 use base 'ShipIt::Step';
  1         2  
  1         1045  
5             our $VERSION = '0.04';
6              
7             sub init {
8 0     0 1   my ($self, $conf) = @_;
9              
10 0   0       $self->{format} = $conf->value('commit_message.format') || '%msg';
11 0           $self->{format} =~ s/%/%%/g;
12 0           $self->{format} =~ s/%%msg/%s/g;
13             }
14              
15             sub run {
16 0     0 1   my ($self, $state) = @_;
17              
18 0           my $pkg = ref($state->vc);
19              
20 0           my $commit = $pkg->can('commit');
21 0           my $tag_version = $pkg->can('tag_version');
22 1     1   354 no strict 'refs';
  1         2  
  1         45  
23 0           *{"$pkg\::commit"} = sub {
24 1     1   5 use strict;
  1         2  
  1         87  
25 0     0     my $c = shift;
26 0           my $msg = shift;
27 0           $msg = sprintf $self->{format}, $msg;
28 0           $commit->($c, $msg, @_);
29 0           };
30 0           *{"$pkg\::tag_version"} = sub {
31 1     1   4 use strict;
  1         4  
  1         71  
32 0     0     my $c = shift;
33 0           my $ver = shift;
34 0           my $msg = shift;
35 0           $msg = sprintf $self->{format}, $msg;
36 0           $tag_version->($c, $ver, $msg, @_);
37 0           };
38 1     1   40 use strict;
  1         3  
  1         71  
39             }
40              
41             1;
42             __END__