line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::RT2Github; |
2
|
1
|
|
|
1
|
|
1268
|
use 5.14.0; |
|
1
|
|
|
|
|
3
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
5
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
6
|
1
|
|
|
1
|
|
573
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
36385
|
|
|
1
|
|
|
|
|
560
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
13
|
|
|
13
|
1
|
16632
|
my ($class, $args) = @_; |
10
|
13
|
100
|
|
|
|
51
|
$args = {} unless defined $args; |
11
|
13
|
100
|
|
|
|
208
|
croak "Argument to new() must be hashref" unless ref($args) eq 'HASH'; |
12
|
12
|
|
|
|
|
21
|
my %valid_args = map {$_ => 1} (qw| timeout |); |
|
12
|
|
|
|
|
49
|
|
13
|
12
|
|
|
|
|
19
|
my @bad_args = (); |
14
|
12
|
|
|
|
|
23
|
while (my ($k,$v) = each(%{$args})) { |
|
14
|
|
|
|
|
49
|
|
15
|
2
|
100
|
|
|
|
6
|
push @bad_args, $k unless $valid_args{$k}; |
16
|
|
|
|
|
|
|
} |
17
|
12
|
100
|
|
|
|
102
|
croak "Bad arguments to new(): @bad_args" if (@bad_args); |
18
|
11
|
|
100
|
|
|
56
|
$args->{timeout} ||= 120; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %data = ( |
21
|
|
|
|
|
|
|
rt_stem => 'https://rt.perl.org/Public/Bug/Display.html?id=', |
22
|
|
|
|
|
|
|
gh_stem => 'https://github.com/perl/perl5/issues/', |
23
|
|
|
|
|
|
|
field => 'location', |
24
|
|
|
|
|
|
|
results => {}, |
25
|
11
|
|
|
|
|
67
|
ua => HTTP::Tiny->new(max_redirect => 0, timeout => $args->{timeout}), |
26
|
|
|
|
|
|
|
); |
27
|
11
|
|
|
|
|
1631
|
my $self = bless \%data, $class; |
28
|
11
|
|
|
|
|
37
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_github_url { |
32
|
13
|
|
|
13
|
1
|
951
|
my ($self, $rt) = @_; |
33
|
13
|
100
|
|
|
|
125
|
croak "RT IDs were numeric" unless $rt =~ m/^\d+$/; |
34
|
12
|
|
|
|
|
40
|
my $rt_url = $self->{rt_stem} . $rt; |
35
|
|
|
|
|
|
|
|
36
|
12
|
|
100
|
|
|
434
|
my $location = $self->{ua}->get($rt_url)->{headers}{$self->{field}} || ''; |
37
|
|
|
|
|
|
|
|
38
|
12
|
100
|
|
|
|
4588031
|
if ($location =~ m{^$self->{gh_stem}\d+$}) { |
39
|
8
|
|
|
|
|
39
|
$self->{results}->{$rt}->{github_url} = $location; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
4
|
|
|
|
|
42
|
$self->{results}->{$rt}->{github_url} = undef; |
43
|
|
|
|
|
|
|
}; |
44
|
12
|
|
|
|
|
53
|
return $self->{results}->{$rt}->{github_url}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_github_urls { |
48
|
2
|
|
|
2
|
1
|
309
|
my ($self, @rt_ids) = @_; |
49
|
2
|
|
|
|
|
4
|
my %urls = (); |
50
|
2
|
|
|
|
|
5
|
for my $rt (@rt_ids) { |
51
|
4
|
|
|
|
|
30
|
my $gh_url = $self->get_github_url($rt); |
52
|
4
|
|
|
|
|
13
|
$urls{$rt} = $gh_url; |
53
|
|
|
|
|
|
|
} |
54
|
2
|
|
|
|
|
11
|
return \%urls; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub get_github_id { |
58
|
7
|
|
|
7
|
1
|
2030
|
my ($self, $rt) = @_; |
59
|
7
|
100
|
|
|
|
179
|
croak "RT IDs were numeric" unless $rt =~ m/^\d+$/; |
60
|
6
|
|
|
|
|
24
|
my $gh_url = $self->get_github_url($rt); |
61
|
6
|
|
|
|
|
11
|
my $gh_id; |
62
|
6
|
100
|
|
|
|
16
|
if (defined $gh_url) { |
63
|
4
|
|
|
|
|
21
|
($gh_id) = $gh_url =~ m{^.*/(.*)$}; |
64
|
4
|
|
|
|
|
16
|
$self->{results}->{$rt}->{github_id} = $gh_id; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
2
|
|
|
|
|
6
|
$self->{results}->{$rt}->{github_id} = undef; |
68
|
|
|
|
|
|
|
} |
69
|
6
|
|
|
|
|
19
|
return $self->{results}->{$rt}->{github_id}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_github_ids { |
73
|
3
|
|
|
3
|
1
|
1000
|
my ($self, @rt_ids) = @_; |
74
|
3
|
|
|
|
|
8
|
my %ids = (); |
75
|
3
|
|
|
|
|
6
|
for my $rt (@rt_ids) { |
76
|
5
|
|
|
|
|
15
|
my $gh_id = $self->get_github_id($rt); |
77
|
4
|
100
|
|
|
|
14
|
if (defined $gh_id) { |
78
|
3
|
|
|
|
|
10
|
$self->{results}->{$rt}->{github_id} = $gh_id; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
1
|
|
|
|
|
4
|
$self->{results}->{$rt}->{github_id} = undef; |
82
|
|
|
|
|
|
|
} |
83
|
4
|
|
|
|
|
13
|
$ids{$rt} = $gh_id; |
84
|
|
|
|
|
|
|
} |
85
|
2
|
|
|
|
|
10
|
return \%ids; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding utf8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Perl::RT2Github - Given RT ticket number, find corresponding Github issue |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SYNOPSIS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
use Perl::RT2Github; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $self = Perl::RT2Github->new(); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $github_url = $self->get_github_url( 125740 ); |
103
|
|
|
|
|
|
|
my $github_urls_ref = $self->get_github_urls( 125740, 133776 ); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $github_id = $self->get_github_id( 125740 ); |
106
|
|
|
|
|
|
|
my $github_ids_ref = $self->get_github_ids( 125740, 133776 ); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
With the recent move of Perl 5 issue tracking from rt.cpan.org to github.com, |
111
|
|
|
|
|
|
|
we need to be able to take a list of RT ticket numbers and look up the |
112
|
|
|
|
|
|
|
corresponding github issue IDs and URLs. This module is a first attempt at |
113
|
|
|
|
|
|
|
doing so. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 C |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 4 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * Purpose |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Perl::RT2Github constructor. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * Arguments |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my $self = Perl::RT2Github->new({ timeout => 120}); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Hash reference; optional. Currently, the only possible element in this hashref is |
130
|
|
|
|
|
|
|
C, whose value defaults to 120 seconds. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * Return Value |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Perl::RT2Github object. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=back |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 C |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * Purpose |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Get github.com URL for old RT ticket number. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * Arguments |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $github_url = $self->get_github_url( 125740 ); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
A single rt.perl.org ticket ID, which must be all-numeric. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * Return Value |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
String holding URL for corresponding github.com issue. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=back |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 C |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=over 4 |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * Purpose |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Get github.com URLs for multiple old RT ticket numbers. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * Arguments |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
my $got = $self->get_github_urls( 125740, 200895 ); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
List of rt.perl.org ticket IDs. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * Return Value |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Hash reference. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=back |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 C |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=over 4 |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * Purpose |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Get github.com issue number for old RT ticket number. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * Arguments |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my $github_id = $self->get_github_id( 125740 ); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
A single rt.perl.org ticket ID, which must be all-numeric. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * Return Value |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
String holding github.com issue number. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=back |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 C |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=over 4 |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * Purpose |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Get github.com ID numbers for multiple old RT ticket numbers. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * Arguments |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
my $github_ids_ref = $self->get_github_ids( 125740, 133776 ); |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
List of RT ticket numbers, which must each be all numeric. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item * Return Value |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Hash reference. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 BUGS |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
None so far. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
The author prefers patches over pull requests on github.com. To report bugs or |
225
|
|
|
|
|
|
|
otherwise contribute to the development of this module, please attach a patch |
226
|
|
|
|
|
|
|
(e.g., output of C) to either (a) an email sent to |
227
|
|
|
|
|
|
|
Cor use the web interface at |
228
|
|
|
|
|
|
|
L. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 AUTHOR |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
James E Keenan |
233
|
|
|
|
|
|
|
CPAN ID: JKEENAN |
234
|
|
|
|
|
|
|
jkeenan@cpan.org |
235
|
|
|
|
|
|
|
http://thenceforward.net/perl |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Implementation suggestions from Dagfinn Ilmari Mannsåker and Dan Book. |
240
|
|
|
|
|
|
|
Correction of error in Changes from Graham Knop. |
241
|
|
|
|
|
|
|
Patch to Makefile.PL from Mohammad S Anwar. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 COPYRIGHT |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
This program is free software; you can redistribute |
246
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
The full text of the license can be found in the |
249
|
|
|
|
|
|
|
LICENSE file included with this module. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 SEE ALSO |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
perl(1). |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
|