File Coverage

blib/lib/App/Slackeria/Plugin/Git.pm
Criterion Covered Total %
statement 24 36 66.6
branch 0 6 0.0
condition n/a
subroutine 8 10 80.0
pod 0 1 0.0
total 32 53 60.3


line stmt bran cond sub pod time code
1             package App::Slackeria::Plugin::Git;
2              
3 1     1   5833203 use strict;
  1         101  
  1         126  
4 1     1   14 use warnings;
  1         2  
  1         96  
5 1     1   1209 use autodie;
  1         64432  
  1         7  
6 1     1   9709 use 5.010;
  1         10  
  1         54  
7              
8 1     1   2384 use parent 'App::Slackeria::Plugin';
  1         515  
  1         6  
9              
10 1     1   8693 use File::Slurp;
  1         22151  
  1         107  
11 1     1   14 use List::Util qw(first);
  1         3  
  1         327  
12 1     1   1233 use Sort::Versions;
  1         943  
  1         926  
13              
14             our $VERSION = '0.12';
15              
16             sub check {
17 0     0 0   my ($self) = @_;
18              
19 0           my $git_dir = sprintf( $self->{conf}->{git_dir}, $self->{conf}->{name} );
20              
21 0           my @tags = split( /\n/, qx{git --git-dir=${git_dir} tag} );
22              
23 0           open( my $fh, '<', "${git_dir}/config" );
24 0 0   0     if ( not first { $_ eq "\tsharedRepository = world\n" } read_file($fh) ) {
  0            
25 0           die("Repo not shared\n");
26             }
27 0           close($fh);
28              
29 0 0         if ( not -e "${git_dir}/git-daemon-export-ok" ) {
30 0           die("git-daemon-export-ok missing\n");
31             }
32              
33             return {
34 0           data => (
35             @tags
36 0 0         ? ( sort { versioncmp( $a, $b ) } @tags )[-1]
37             : q{}
38             ),
39             };
40             }
41              
42             1;
43              
44             __END__