| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::GitHubWebhooks2Ikachan::Events::Push; |
|
2
|
2
|
|
|
2
|
|
1035
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
76
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
49
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
12
|
|
|
5
|
2
|
|
|
2
|
|
784
|
use String::IRC; |
|
|
2
|
|
|
|
|
863
|
|
|
|
2
|
|
|
|
|
749
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub call { |
|
8
|
2
|
|
|
2
|
0
|
4
|
my ($class, $context) = @_; |
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
|
|
8
|
my $dat = $context->dat; |
|
11
|
2
|
|
|
|
|
18
|
my $branch = __PACKAGE__->_extract_branch_name($dat); |
|
12
|
|
|
|
|
|
|
|
|
13
|
2
|
|
|
|
|
5
|
my $texts = []; |
|
14
|
2
|
50
|
|
|
|
2
|
for my $commit (@{$dat->{commits} || []}) { |
|
|
2
|
|
|
|
|
8
|
|
|
15
|
5
|
100
|
|
|
|
141
|
next if $commit->{distinct} == 0; # to squash duplicated commit |
|
16
|
|
|
|
|
|
|
|
|
17
|
3
|
|
0
|
|
|
23
|
my $user_name = $commit->{author}->{username} |
|
18
|
|
|
|
|
|
|
|| $commit->{author}->{name} |
|
19
|
|
|
|
|
|
|
|| $commit->{committer}->{username} |
|
20
|
|
|
|
|
|
|
|| $commit->{committer}->{name}; |
|
21
|
3
|
|
|
|
|
11
|
(my $commit_message = $commit->{message}) =~ s/\r?\n.*//g; |
|
22
|
3
|
|
|
|
|
5
|
my $url = $commit->{url}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
9
|
my $main_text = "[push to $branch] $commit_message (\@$user_name)"; |
|
25
|
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
11
|
push @$texts, String::IRC->new($main_text)->green . " $url"; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
55
|
return $texts; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _extract_branch_name { |
|
33
|
2
|
|
|
2
|
|
5
|
my ($class, $dat) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# e.g. |
|
36
|
|
|
|
|
|
|
# ref: "refs/heads/__BRANCH_NAME__" |
|
37
|
2
|
|
|
|
|
2
|
my $branch; |
|
38
|
2
|
50
|
|
|
|
8
|
if (my $ref = $dat->{ref}) { |
|
39
|
2
|
|
|
|
|
13
|
$branch = (split qr!/!, $ref)[-1]; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
50
|
|
|
|
10
|
return $branch ? $branch : ''; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
|
46
|
|
|
|
|
|
|
|