line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
231899
|
use 5.014; # because we use the 'state' and 'non-destructive substitution' feature (s///r) |
|
1
|
|
|
|
|
15
|
|
2
|
1
|
|
|
1
|
|
16
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
73
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
171
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Banal::Dist::Util::Git; |
6
|
|
|
|
|
|
|
# vim: set ts=2 sts=2 sw=2 tw=115 et : |
7
|
|
|
|
|
|
|
# ABSTRACT: General purpose utility collection for |
8
|
|
|
|
|
|
|
# KEYWORDS: author utility |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
11
|
|
|
|
|
|
|
# AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
889
|
use Path::Tiny; |
|
1
|
|
|
|
|
13567
|
|
|
1
|
|
|
|
|
112
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
7
|
use Exporter::Shiny qw( |
16
|
|
|
|
|
|
|
detect_settings_from_git |
17
|
1
|
|
|
1
|
|
471
|
); |
|
1
|
|
|
|
|
4241
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
523
|
use namespace::autoclean; |
|
1
|
|
|
|
|
18771
|
|
|
1
|
|
|
|
|
5
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Detect settings (like remote 'server') from the local git repository |
23
|
|
|
|
|
|
|
sub detect_settings_from_git { |
24
|
0
|
|
|
0
|
0
|
|
my %args = @_; |
25
|
0
|
|
0
|
|
|
|
my $dir = $args{dir} || Path::Tiny->cwd; |
26
|
0
|
|
|
|
|
|
my %detected; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
REMOTE: { |
29
|
0
|
|
|
|
|
|
eval { |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $git = Git::Wrapper->new( $dir ); |
31
|
0
|
|
|
|
|
|
my @lines = $git->remote( {v=>1} ); |
32
|
0
|
|
0
|
|
|
|
/^(\S+)\s+(\S+)\s+\(fetch\)$/i and $detected{remotes}{$1}=$2 foreach (@lines); |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
0
|
|
|
|
last REMOTE unless ( exists $detected{remotes} ) && ( exists $detected{remotes}{origin} ); |
36
|
0
|
0
|
|
|
|
|
last REMOTE unless $detected{remotes}{origin} =~ qr{^ (https?|git):/(?.*)?/ |
37
|
|
|
|
|
|
|
(? .* ) / (:? (? .*) /)? (? .*) \.git$}xi; |
38
|
1
|
|
|
1
|
|
750
|
my ($domain, $folder) = ( $+{domain}, $+{folder} ); |
|
1
|
|
|
|
|
414
|
|
|
1
|
|
|
|
|
281
|
|
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ( $domain =~ /^((?github)\.com) | ((?bitbucket)\.org)$/xi) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $server = $detected{server} = $+{server}; |
42
|
0
|
|
|
|
|
|
$detected{"server_amr_opt_${server}"}= "user:${folder}"; # for [AutoMetaResources] |
43
|
|
|
|
|
|
|
} elsif ( $domain =~ /^git\.moose\.perl\.org$/xi ) { |
44
|
0
|
|
|
|
|
|
$detected{server} = 'gitmo'; |
45
|
|
|
|
|
|
|
} elsif ( $domain =~ /^git\.shadowcat\.co\.uk$/xi ) { |
46
|
0
|
0
|
|
|
|
|
$detected{server} = $folder if $folder =~ /^catagits|p5sagit|dbsrgits$/; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
0
|
0
|
|
|
|
|
wantarray ? (%detected) : \%detected; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |