line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::RT2Github; |
2
|
1
|
|
|
1
|
|
1741
|
use 5.14.0; |
|
1
|
|
|
|
|
3
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04_005'; |
5
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
145
|
|
6
|
1
|
|
|
1
|
|
702
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
45565
|
|
|
1
|
|
|
|
|
595
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
1
|
1210
|
my ($class, $args) = @_; |
10
|
3
|
50
|
|
|
|
12
|
$args = {} unless defined $args; |
11
|
3
|
100
|
|
|
|
179
|
croak "Argument to new() must be hashref" unless ref($args) eq 'HASH'; |
12
|
2
|
|
|
|
|
3
|
my %valid_args = map {$_ => 1} (qw| timeout |); |
|
2
|
|
|
|
|
7
|
|
13
|
2
|
|
|
|
|
5
|
my @bad_args = (); |
14
|
2
|
|
|
|
|
2
|
while (my ($k,$v) = each(%{$args})) { |
|
4
|
|
|
|
|
12
|
|
15
|
2
|
100
|
|
|
|
6
|
push @bad_args, $k unless $valid_args{$k}; |
16
|
|
|
|
|
|
|
} |
17
|
2
|
100
|
|
|
|
119
|
croak "Bad arguments to new(): @bad_args" if (@bad_args); |
18
|
1
|
|
50
|
|
|
3
|
$args->{timeout} ||= 20; |
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
|
1
|
|
|
|
|
5
|
ua => HTTP::Tiny->new(max_redirect => 0, timeout => $args->{timeout}), |
26
|
|
|
|
|
|
|
); |
27
|
1
|
|
|
|
|
87
|
my $self = bless \%data, $class; |
28
|
1
|
|
|
|
|
3
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_github_url { |
32
|
0
|
|
|
0
|
1
|
|
my ($self, $rt) = @_; |
33
|
0
|
0
|
|
|
|
|
croak "RT IDs were numeric" unless $rt =~ m/^\d+$/; |
34
|
0
|
|
|
|
|
|
my $rt_url = $self->{rt_stem} . $rt; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
0
|
|
|
|
my $location = $self->{ua}->get($rt_url)->{headers}{$self->{field}} || ''; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if ($location =~ m{^$self->{gh_stem}\d+$}) { |
39
|
0
|
|
|
|
|
|
$self->{results}->{$rt}->{github_url} = $location; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
0
|
|
|
|
|
|
$self->{results}->{$rt}->{github_url} = undef; |
43
|
|
|
|
|
|
|
}; |
44
|
0
|
|
|
|
|
|
return $self->{results}->{$rt}->{github_url}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_github_urls { |
48
|
0
|
|
|
0
|
1
|
|
my ($self, @rt_ids) = @_; |
49
|
0
|
|
|
|
|
|
my %urls = (); |
50
|
0
|
|
|
|
|
|
for my $rt (@rt_ids) { |
51
|
0
|
|
|
|
|
|
my $gh_url = $self->get_github_url($rt); |
52
|
0
|
|
|
|
|
|
$urls{$rt} = $gh_url; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
|
return \%urls; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub get_github_id { |
58
|
0
|
|
|
0
|
1
|
|
my ($self, $rt) = @_; |
59
|
0
|
0
|
|
|
|
|
croak "RT IDs were numeric" unless $rt =~ m/^\d+$/; |
60
|
0
|
|
|
|
|
|
my $gh_url = $self->get_github_url($rt); |
61
|
0
|
|
|
|
|
|
my $gh_id; |
62
|
0
|
0
|
|
|
|
|
if (defined $gh_url) { |
63
|
0
|
|
|
|
|
|
($gh_id) = $gh_url =~ m{^.*/(.*)$}; |
64
|
0
|
|
|
|
|
|
$self->{results}->{$rt}->{github_id} = $gh_id; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
0
|
|
|
|
|
|
$self->{results}->{$rt}->{github_id} = undef; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
return $self->{results}->{$rt}->{github_id}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_github_ids { |
73
|
0
|
|
|
0
|
1
|
|
my ($self, @rt_ids) = @_; |
74
|
0
|
|
|
|
|
|
my %ids = (); |
75
|
0
|
|
|
|
|
|
for my $rt (@rt_ids) { |
76
|
0
|
|
|
|
|
|
my $gh_id = $self->get_github_id($rt); |
77
|
0
|
0
|
|
|
|
|
if (defined $gh_id) { |
78
|
0
|
|
|
|
|
|
$self->{results}->{$rt}->{github_id} = $gh_id; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
|
$self->{results}->{$rt}->{github_id} = undef; |
82
|
|
|
|
|
|
|
} |
83
|
0
|
|
|
|
|
|
$ids{$rt} = $gh_id; |
84
|
|
|
|
|
|
|
} |
85
|
0
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|