File Coverage

blib/lib/Minilla/Release/Commit.pm
Criterion Covered Total %
statement 15 32 46.8
branch 0 6 0.0
condition n/a
subroutine 5 7 71.4
pod 0 1 0.0
total 20 46 43.4


line stmt bran cond sub pod time code
1             package Minilla::Release::Commit;
2 1     1   920 use strict;
  1         3  
  1         27  
3 1     1   4 use warnings;
  1         2  
  1         22  
4 1     1   5 use utf8;
  1         1  
  1         6  
5              
6 1     1   37 use Minilla::Util qw(find_file cmd);
  1         2  
  1         47  
7 1     1   6 use Minilla::Logger;
  1         2  
  1         323  
8              
9             sub run {
10 0     0 0   my ($self, $project, $opts) = @_;
11              
12 0           my @modified_files = split /\0/, `git ls-files --deleted --modified -z`;
13 0 0         return if @modified_files == 0;
14              
15 0           $project->clear_metadata();
16 0           my $ver = $project->metadata->version;
17              
18 0           my $msg = "Checking in changes prior to tagging of version $ver.\n\nChangelog diff is:\n\n";
19 0           $msg .= `git diff Changes`;
20              
21 0 0         if ($opts->{dry_run}) {
22 0           infof("DRY-RUN. Would have committed message of:\n----------------\n$msg\n-----------\n");
23 0           return;
24             }
25              
26 0           cmd('git', 'commit', '-a', '-m', $msg, '--cleanup=verbatim');
27              
28 0           $self->_push_to_origin();
29             }
30              
31             sub _push_to_origin {
32 0     0     my ($self) = @_;
33              
34             # git v1.7.10 is required?
35 0 0         my $branch = `git symbolic-ref --short HEAD`
36             or return;
37 0           $branch =~ s/\n//g;
38 0           infof("Pushing to origin\n");
39 0           cmd('git', 'push', 'origin', $branch);
40             }
41              
42             1;
43