line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::UpdateGitHub; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
4948
|
$Dist::Zilla::Plugin::UpdateGitHub::VERSION = '0.0019'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Update your github repository description from abstract on release |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
11
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
with qw/ Dist::Zilla::Role::Releaser /; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
9455
|
use Config::Identity::GitHub; |
|
1
|
|
|
|
|
67277
|
|
|
1
|
|
|
|
|
14
|
|
12
|
1
|
|
|
1
|
|
1467
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
68394
|
|
|
1
|
|
|
|
|
16
|
|
13
|
|
|
|
|
|
|
my $agent = LWP::UserAgent->new; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub update { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
|
|
|
|
|
my %given = @_; |
18
|
0
|
|
|
|
|
|
my ( $login, $token, $repository, $description ); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
( $repository, $description ) = @given{qw/ repository description /}; |
21
|
0
|
|
0
|
|
|
|
defined $_ && length $_ or die "Missing repository" for $repository; |
|
|
|
0
|
|
|
|
|
22
|
0
|
|
0
|
|
|
|
defined $_ && length $_ or die "Missing description" for $description; |
|
|
|
0
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
( $login, $token ) = @given{qw/ login token /}; |
25
|
0
|
0
|
0
|
|
|
|
unless( defined $token && length $token ) { |
26
|
0
|
|
|
|
|
|
my %identity = Config::Identity::GitHub->load; |
27
|
0
|
|
|
|
|
|
( $login, $token ) = @identity{qw/ login token /}; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
for ( $login, $token ) { |
30
|
0
|
0
|
0
|
|
|
|
unless ( defined $_ and length $_ ) { |
31
|
0
|
|
|
|
|
|
$self->log( 'Missing GitHub login and/or token' ); |
32
|
0
|
|
|
|
|
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $uri = "https://github.com/api/v2/json/repos/show/$login/$repository"; |
37
|
0
|
|
|
|
|
|
my $response = $agent->post( $uri, |
38
|
|
|
|
|
|
|
[ login => $login, token => $token, 'values[description]' => $description ] ); |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
unless ( $response->is_success ) { |
41
|
0
|
|
|
|
|
|
die $response->status_line, "\n", |
42
|
|
|
|
|
|
|
$response->decoded_content; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return $response; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub release { |
49
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $repository = $self->zilla->name; |
52
|
0
|
|
|
|
|
|
my $description = $self->zilla->abstract; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
eval { |
55
|
0
|
0
|
|
|
|
|
if ( my $response = $self->update( repository => $repository, description => $description ) ) { |
56
|
0
|
|
|
|
|
|
$self->log( "Updated github description:", $response->decoded_content ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
}; |
59
|
0
|
0
|
|
|
|
|
$self->log( "Unable to update github description: $@" ) if $@; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
63
|
1
|
|
|
1
|
|
467
|
no Moose; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
12
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Dist::Zilla::Plugin::UpdateGitHub - Update your github repository description from abstract on release |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.0019 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
In your L<Dist::Zilla> C<dist.ini>: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
[UpdateGitHub] |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Dist::Zilla::Plugin::UpdateGitHub will automatically update your github repository |
86
|
|
|
|
|
|
|
description to be the same as your abstract on release |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
It will infer the repository name from the distribution name, and get your login/token from C<$HOME/.github> or C<$HOME/.github-identity> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 FUTURE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
More complicated repository inferring |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Update homepage as well |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SEE ALSO |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L<App::GitHub::update> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L<Config::Identity> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Robert Krimen <robertkrimen@gmail.com> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Robert Krimen. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
111
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|