line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Github::Fork::Parent;
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
738471
|
use 5.006;
|
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings;
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
122
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Github::Fork::Parent - Perl module to determine which repository stands in a root of GitHub forking hierarhy.
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.24
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.24';
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $parent_url = github_parent('git://github.com/chorny/plagger.git');
|
23
|
|
|
|
|
|
|
#returns https://github.com/miyagawa/plagger
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 FUNCTIONS
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 github_parent
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Takes link to repository (git://, git@ or http://) and returns http link to root repository.
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 github_parent_author
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Takes link to repository (git://, git@ or http://) and returns owner of root repository.
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut
|
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
2
|
|
2138
|
use JSON;
|
|
2
|
|
|
|
|
2893239
|
|
|
2
|
|
|
|
|
16
|
|
38
|
|
|
|
|
|
|
#use YAML::Tiny 1.40;
|
39
|
2
|
|
|
2
|
|
2292
|
use LWP::UserAgent;
|
|
2
|
|
|
|
|
15380779
|
|
|
2
|
|
|
|
|
72
|
|
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
2
|
|
17
|
use Exporter 'import';
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1250
|
|
42
|
|
|
|
|
|
|
our @EXPORT = qw(github_parent github_parent_author);
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_repo_data {
|
45
|
4
|
|
|
4
|
0
|
7
|
my ($author,$project)=@_;
|
46
|
|
|
|
|
|
|
#my $url = "http://github.com/api/v2/yaml/repos/show/$author/$project/network";
|
47
|
4
|
|
|
|
|
15
|
my $url = "https://api.github.com/repos/$author/$project";
|
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
38
|
my $ua=LWP::UserAgent->new();
|
50
|
4
|
|
|
|
|
982
|
$ua->timeout(50);
|
51
|
4
|
|
|
|
|
115
|
my $response = $ua->get($url);
|
52
|
4
|
50
|
|
|
|
2127717
|
if ($response->is_success) {
|
53
|
4
|
|
|
|
|
66
|
my $yaml = $response->content();
|
54
|
4
|
|
|
|
|
1797
|
return $yaml;
|
55
|
|
|
|
|
|
|
} else {
|
56
|
0
|
0
|
|
|
|
0
|
if ($response->code eq '404') {
|
57
|
0
|
|
|
|
|
0
|
return undef;
|
58
|
|
|
|
|
|
|
} else {
|
59
|
0
|
|
|
|
|
0
|
die "Could not GET data (".$response->status_line.")";
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub parse_github_links {
|
65
|
5
|
|
|
5
|
0
|
762
|
my $link=shift;
|
66
|
5
|
50
|
|
|
|
56
|
if ($link=~m#^(?:\Qgit://github.com/\E|git\@github\.com:|https?://github\.com/)([^/]+)/([^/.]+)(?:\.git)?$#) {
|
67
|
5
|
|
|
|
|
26
|
return ($1,$2);
|
68
|
|
|
|
|
|
|
} else {
|
69
|
0
|
|
|
|
|
0
|
return (undef,undef);
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub github_parent {
|
75
|
2
|
|
|
2
|
1
|
5094005
|
my $link=shift;
|
76
|
2
|
|
|
|
|
9
|
my ($author,$project)=parse_github_links($link);
|
77
|
2
|
50
|
|
|
|
10
|
return $link unless $author;
|
78
|
2
|
|
|
|
|
7
|
my $yaml_content=get_repo_data($author,$project);
|
79
|
2
|
50
|
|
|
|
9
|
if ($yaml_content) {
|
80
|
|
|
|
|
|
|
#my $yaml=YAML::Tiny->read_string($yaml_content) or die;
|
81
|
2
|
|
|
|
|
386
|
my $yaml=decode_json($yaml_content);
|
82
|
2
|
|
|
|
|
7
|
my $source_url=$yaml->{source}{html_url};
|
83
|
2
|
50
|
|
|
|
8
|
die unless $source_url;
|
84
|
2
|
|
|
|
|
78
|
return $source_url;
|
85
|
|
|
|
|
|
|
} else {
|
86
|
0
|
|
|
|
|
0
|
die "No content for $author/$project";
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub github_parent_author {
|
91
|
|
|
|
|
|
|
#my $link=shift;
|
92
|
|
|
|
|
|
|
#my $link1=github_parent($link);
|
93
|
|
|
|
|
|
|
#my ($author,$project)=parse_github_links($link1);
|
94
|
|
|
|
|
|
|
#die "Cannot get author from '$link1'" unless $author;
|
95
|
|
|
|
|
|
|
#return $author;
|
96
|
2
|
|
|
2
|
1
|
7
|
my $link=shift;
|
97
|
2
|
|
|
|
|
10
|
my ($author,$project)=parse_github_links($link);
|
98
|
2
|
50
|
|
|
|
13
|
return $link unless $author;
|
99
|
2
|
|
|
|
|
9
|
my $yaml_content=get_repo_data($author,$project);
|
100
|
2
|
50
|
|
|
|
15
|
if ($yaml_content) {
|
101
|
|
|
|
|
|
|
#my $yaml=YAML::Tiny->read_string($yaml_content) or die;
|
102
|
2
|
|
|
|
|
407
|
my $yaml=decode_json($yaml_content);
|
103
|
2
|
100
|
|
|
|
88
|
return $author unless $yaml->{'fork'};
|
104
|
1
|
|
|
|
|
19
|
my $source=$yaml->{source}{owner}{login};
|
105
|
1
|
50
|
|
|
|
7
|
die "No login in YAML for $link" unless $source;
|
106
|
1
|
|
|
|
|
63
|
return $source;
|
107
|
0
|
|
|
|
|
|
die;
|
108
|
|
|
|
|
|
|
} else {
|
109
|
0
|
|
|
|
|
|
die "No content";
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
}
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Alexandr Ciornii, C<< >>
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 BUGS
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through
|
120
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll
|
121
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes.
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 SUPPORT
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command.
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
perldoc Github::Fork::Parent
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
You can also look for information at:
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=over 4
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
L
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * CPAN Ratings
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * Search CPAN
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SEE ALSO
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Net::GitHub
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Copyright 2009-2016 Alexandr Ciornii.
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
165
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published
|
166
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License.
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information.
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; # End of Github::Fork::Parent
|