line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Debugbar::Monitor::Git; |
2
|
1
|
|
|
1
|
|
54033
|
use Mojo::Base "Mojo::Debugbar::Monitor"; |
|
1
|
|
|
|
|
156972
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has 'icon' => ''; |
5
|
|
|
|
|
|
|
has 'name' => 'Git'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head2 render |
8
|
|
|
|
|
|
|
Returns the html |
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub render { |
12
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $rows = ''; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
foreach my $item (@{ $self->items }) { |
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$rows .= sprintf( |
18
|
|
|
|
|
|
|
' |
19
|
|
|
|
|
|
|
| %s |
20
|
|
|
|
|
|
|
| %s |
21
|
|
|
|
|
|
|
|
',
22
|
|
|
|
|
|
|
$item->{ field }, $item->{ field }, $item->{ message } |
23
|
0
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return sprintf( |
27
|
|
|
|
|
|
|
'', |
38
|
|
|
|
|
|
|
$rows |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 start |
43
|
|
|
|
|
|
|
Listen for "after_dispatch" event and if there's anything in stash for validate_tiny.errors key, |
44
|
|
|
|
|
|
|
store the field name and the error |
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub start { |
48
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$self->app->hook(after_dispatch => sub { |
51
|
0
|
|
|
0
|
|
|
my $c = shift; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $home = $self->app->home; |
54
|
0
|
|
|
|
|
|
my $gitinfo = $self->git_info($home); |
55
|
0
|
|
|
|
|
|
my @items; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
push(@items, { field => $_, message => $gitinfo->{ $_ } }) for keys(%$gitinfo); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->items(\@items); |
60
|
0
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub git_info { |
64
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
65
|
0
|
|
|
|
|
|
my $home = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $command = "/usr/bin/git --no-pager -C $home log -n1 --no-color --decorate"; |
69
|
0
|
|
|
|
|
|
my $old_path = $ENV{'PATH'}; |
70
|
0
|
|
|
|
|
|
$old_path =~ /(.+)/; |
71
|
0
|
|
|
|
|
|
$old_path = $1; |
72
|
0
|
|
|
|
|
|
$ENV{'PATH'} = $old_path . ':/usr/local/bin'; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $git_output = `$command`; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$git_output =~ //; |
77
|
0
|
|
|
|
|
|
my @lines = split /[\r\n]+/, $git_output; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $line = shift @lines; |
80
|
0
|
|
|
|
|
|
my ($commit, $branch) = $line =~ /commit (\w+) .+ -> ([^,]+),.+/g; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$line = shift @lines; |
84
|
0
|
|
|
|
|
|
my ($author) = $line =~ /Author: (.+) <(.+)/; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$line = shift @lines; |
88
|
0
|
|
|
|
|
|
my ($date) = $line =~ /Date: (.+)/; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $comment = join ', ', @lines; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return { |
94
|
0
|
|
|
|
|
|
branch => $branch, |
95
|
|
|
|
|
|
|
commit => $commit, |
96
|
|
|
|
|
|
|
author => $author, |
97
|
|
|
|
|
|
|
date => $date, |
98
|
|
|
|
|
|
|
comment => $comment |
99
|
|
|
|
|
|
|
}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |