line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Moo; |
3
|
2
|
|
|
2
|
|
155444
|
|
|
2
|
|
|
|
|
11510
|
|
|
2
|
|
|
|
|
18
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.000009'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use GitHub::MergeVelocity::Repository::PullRequest (); |
7
|
2
|
|
|
2
|
|
2826
|
use GitHub::MergeVelocity::Repository::Statistics (); |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
52
|
|
8
|
2
|
|
|
2
|
|
813
|
use MooX::StrictConstructor; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
48
|
|
9
|
2
|
|
|
2
|
|
12
|
use Types::Standard qw( ArrayRef Bool InstanceOf Str ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
10
|
2
|
|
|
2
|
|
1394
|
use URI (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
11
|
2
|
|
|
2
|
|
2386
|
|
|
2
|
|
|
|
|
8084
|
|
|
2
|
|
|
|
|
1058
|
|
12
|
|
|
|
|
|
|
has github_client => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
isa => InstanceOf ['Pithub::PullRequests'], |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has name => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => Str, |
21
|
|
|
|
|
|
|
init_arg => undef, |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
default => sub { |
24
|
|
|
|
|
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
my ( undef, $name ) = $self->_parse_github_url( $self->url ); |
26
|
|
|
|
|
|
|
return $name; |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has report => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => InstanceOf ['GitHub::MergeVelocity::Repository::Statistics'], |
33
|
|
|
|
|
|
|
init_arg => undef, |
34
|
|
|
|
|
|
|
lazy => 1, |
35
|
|
|
|
|
|
|
builder => '_build_report', |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has url => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
isa => Str, |
41
|
|
|
|
|
|
|
required => 1, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has user => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => Str, |
47
|
|
|
|
|
|
|
init_arg => undef, |
48
|
|
|
|
|
|
|
lazy => 1, |
49
|
|
|
|
|
|
|
default => sub { |
50
|
|
|
|
|
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
my ($user) = $self->_parse_github_url( $self->url ); |
52
|
|
|
|
|
|
|
return $user; |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
|
14
|
my $pulls = $self->_get_pull_requests; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
4
|
my $total = $pulls ? scalar @{$pulls} : 0; |
61
|
|
|
|
|
|
|
|
62
|
1
|
50
|
|
|
|
14
|
my %summary = ( total_velocity => 0 ); |
|
1
|
|
|
|
|
3
|
|
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
5
|
foreach my $pr ( @{$pulls} ) { |
65
|
|
|
|
|
|
|
$summary{ $pr->state }++; |
66
|
1
|
|
|
|
|
3
|
$summary{ $pr->state . '_age' } += $pr->age; |
|
1
|
|
|
|
|
4
|
|
67
|
23
|
|
|
|
|
807
|
$summary{total_velocity} += $pr->velocity; |
68
|
23
|
|
|
|
|
714
|
} |
69
|
23
|
|
|
|
|
3216
|
|
70
|
|
|
|
|
|
|
return GitHub::MergeVelocity::Repository::Statistics->new(%summary); |
71
|
|
|
|
|
|
|
} |
72
|
1
|
|
|
|
|
41
|
|
73
|
|
|
|
|
|
|
## no critic (ValuesAndExpressions::ProhibitAccessOfPrivateData) |
74
|
|
|
|
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $result = $self->github_client->list( |
77
|
1
|
|
|
1
|
|
2
|
user => $self->user, |
78
|
|
|
|
|
|
|
repo => $self->name, |
79
|
1
|
|
|
|
|
19
|
params => { per_page => 100, state => 'all' }, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$result->auto_pagination(1); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my @pulls; |
85
|
1
|
|
|
|
|
1037004
|
|
86
|
|
|
|
|
|
|
while ( my $row = $result->next ) { |
87
|
1
|
|
|
|
|
4
|
|
88
|
|
|
|
|
|
|
# GunioRobot seems to create pull requests that clean up whitespace |
89
|
1
|
|
|
|
|
6
|
next if !$row->{user} || $row->{user}->{login} eq 'GunioRobot'; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $pull_request |
92
|
23
|
50
|
33
|
|
|
6608
|
= GitHub::MergeVelocity::Repository::PullRequest->new( |
93
|
|
|
|
|
|
|
created_at => $row->{created_at}, |
94
|
|
|
|
|
|
|
$row->{closed_at} ? ( closed_at => $row->{closed_at} ) : (), |
95
|
|
|
|
|
|
|
$row->{merged_at} ? ( merged_at => $row->{merged_at} ) : (), |
96
|
|
|
|
|
|
|
number => $row->{number}, |
97
|
|
|
|
|
|
|
title => $row->{title}, |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
push @pulls, $pull_request; |
101
|
23
|
100
|
|
|
|
472
|
} |
|
|
100
|
|
|
|
|
|
102
|
|
|
|
|
|
|
return \@pulls; |
103
|
23
|
|
|
|
|
11602
|
} |
104
|
|
|
|
|
|
|
## use critic |
105
|
1
|
|
|
|
|
1203
|
|
106
|
|
|
|
|
|
|
my $self = shift; |
107
|
|
|
|
|
|
|
my $uri = URI->new(shift); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my @parts = split m{/}, $uri->path; |
110
|
12
|
|
|
12
|
|
20
|
|
111
|
12
|
|
|
|
|
36
|
# paths may or may not have a leading slash (absolute vs relative) |
112
|
|
|
|
|
|
|
my $user = shift @parts || shift @parts; |
113
|
12
|
|
|
|
|
708
|
my $name = shift @parts; |
114
|
|
|
|
|
|
|
$name =~ s{\.git}{}; |
115
|
|
|
|
|
|
|
|
116
|
12
|
|
66
|
|
|
312
|
return ( $user, $name ); |
117
|
12
|
|
|
|
|
24
|
} |
118
|
12
|
|
|
|
|
28
|
|
119
|
|
|
|
|
|
|
1; |
120
|
12
|
|
|
|
|
47
|
|
121
|
|
|
|
|
|
|
=pod |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=encoding UTF-8 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 NAME |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
GitHub::MergeVelocity::Repository - Encapsulate pull request data for a repository |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 VERSION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
version 0.000009 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 AUTHOR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Olaf Alders <olaf@wundercounter.com> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Olaf Alders. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
142
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# ABSTRACT: Encapsulate pull request data for a repository |
148
|
|
|
|
|
|
|
|