line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Repository::Plugin::Info; |
2
|
1
|
|
|
1
|
|
1510
|
use parent qw(Git::Repository::Plugin); |
|
1
|
|
|
|
|
296
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use 5.008005; |
5
|
|
|
|
|
|
|
use strict; |
6
|
|
|
|
|
|
|
use warnings; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _keywords { qw( |
11
|
|
|
|
|
|
|
is_bare |
12
|
|
|
|
|
|
|
has_ref |
13
|
|
|
|
|
|
|
has_branch |
14
|
|
|
|
|
|
|
has_tag |
15
|
|
|
|
|
|
|
) } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub is_bare { |
18
|
|
|
|
|
|
|
my $repo = shift; |
19
|
|
|
|
|
|
|
return _bool_config($repo, 'core.bare'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub has_ref { |
23
|
|
|
|
|
|
|
my $repo = shift; |
24
|
|
|
|
|
|
|
my $ref_name = shift; |
25
|
|
|
|
|
|
|
$repo->run('show-ref', '--verify', '--quiet', $ref_name); |
26
|
|
|
|
|
|
|
return ($? == 0); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub has_branch { |
30
|
|
|
|
|
|
|
my $repo = shift; |
31
|
|
|
|
|
|
|
my $branch_name = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# normalize branch name to prevent ambiguous matches to tags, etc. |
34
|
|
|
|
|
|
|
unless (index($branch_name, 'refs/heads/') == 0) { |
35
|
|
|
|
|
|
|
$branch_name = 'refs/heads/' . $branch_name; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $repo->has_ref($branch_name); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub has_tag { |
42
|
|
|
|
|
|
|
my $repo = shift; |
43
|
|
|
|
|
|
|
my $tag_name = shift; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# normalize tag name to prevent ambiguous matches to tags, etc. |
46
|
|
|
|
|
|
|
unless (index($tag_name, 'refs/tags/') == 0) { |
47
|
|
|
|
|
|
|
$tag_name = 'refs/tags/' . $tag_name; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $repo->has_ref($tag_name); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _bool_config { |
54
|
|
|
|
|
|
|
my $repo = shift; |
55
|
|
|
|
|
|
|
my $key = shift; |
56
|
|
|
|
|
|
|
my $bare = $repo->run('config', '--bool', $key); |
57
|
|
|
|
|
|
|
return ($bare eq 'true'); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |