line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::GitLab::Update 1.0001; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2878393
|
use Modern::Perl; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
4
|
1
|
|
|
1
|
|
188
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
77
|
|
5
|
1
|
|
|
1
|
|
10
|
use JSON::MaybeXS; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
83
|
|
6
|
1
|
|
|
1
|
|
11
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
7150
|
use List::Util qw(first); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
87
|
|
8
|
1
|
|
|
1
|
|
485
|
use URL::Encode qw(url_encode_utf8); |
|
1
|
|
|
|
|
5706
|
|
|
1
|
|
|
|
|
475
|
|
9
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::GitLab'; |
10
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::AfterRelease'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub after_release { |
13
|
1
|
|
|
1
|
0
|
278420
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
1
|
50
|
|
|
|
75
|
return if ( !$self->_has_credentials ); |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
60
|
my $repo_name = $self->_get_repo_name( $self->_credentials->{login} ); |
18
|
1
|
50
|
|
|
|
25
|
if ( not $repo_name ) { |
19
|
0
|
|
|
|
|
0
|
$self->log('cannot update GitLab repository info'); |
20
|
0
|
|
|
|
|
0
|
return; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
71
|
my $params = { |
24
|
|
|
|
|
|
|
name => ( $repo_name =~ /\/(.*)$/ )[0], |
25
|
|
|
|
|
|
|
description => $self->zilla->abstract, |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
103
|
$self->log('Updating GitLab repository info'); |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
388
|
my $url = $self->api . '/projects/' . url_encode_utf8($repo_name); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
51
|
my $current = $self->_current_params($url); |
33
|
1
|
50
|
50
|
|
|
80
|
if ( $current |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
|
|
|
|
&& ( $current->{name} || q{} ) eq $params->{name} |
35
|
|
|
|
|
|
|
&& ( $current->{description} || q{} ) eq $params->{description} ) { |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
$self->log('GitLab repo info is up to date'); |
38
|
0
|
|
|
|
|
0
|
return; |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
15
|
my $headers = $self->_auth_headers; |
41
|
1
|
|
|
|
|
104
|
$headers->{'content-type'} = 'application/json'; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
9
|
$self->log_debug("Sending PUT $url"); |
44
|
1
|
|
|
|
|
311
|
my $response = HTTP::Tiny->new->request( |
45
|
|
|
|
|
|
|
'PUT', $url, |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
content => encode_json($params), |
48
|
|
|
|
|
|
|
headers => $headers, |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
116
|
my $repo = $self->_check_response($response); |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
|
|
|
45
|
return if not $repo; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _current_params { |
58
|
1
|
|
|
1
|
|
8
|
my $self = shift; |
59
|
1
|
|
|
|
|
11
|
my ($url) = @_; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
30
|
my $http = HTTP::Tiny->new; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
270
|
$self->log_debug("Sending GET $url"); |
64
|
1
|
|
|
|
|
489
|
my $response = $http->request( 'GET', $url ); |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
62
|
return $self->_check_response($response); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=pod |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=encoding UTF-8 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Dist::Zilla::Plugin::GitLab::Update - Update a GitLab repo's info on release |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
version 1.0001 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Configure git with your GitLab login name: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$ git config --global gitlab.user LoginName |
90
|
|
|
|
|
|
|
$ git config --global gitlab.token AccessToken |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Set up an access token on GitLab, in your profile under "Personal Access Tokens." You |
93
|
|
|
|
|
|
|
must grant the token the C<api> scope! |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
then, in your F<dist.ini>: |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# default config |
98
|
|
|
|
|
|
|
[GitLab::Update] |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# to override the repo name |
101
|
|
|
|
|
|
|
[GitLab::Update] |
102
|
|
|
|
|
|
|
repo = SomeRepo |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
See L</ATTRIBUTES> for more options. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DESCRIPTION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This Dist::Zilla plugin updates the information of the GitLab repository |
109
|
|
|
|
|
|
|
when C<dzil release> is run. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item C<remote> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Specifies the git remote name to be used when guessing the repo name (default C<origin>). |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item C<repo> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The name of the GitLab repository. By default the name will be extracted from |
122
|
|
|
|
|
|
|
the URL of the remote specified in the C<remote> option, and if that fails the |
123
|
|
|
|
|
|
|
dist name (from dist.ini) is used. It can also be in the form C<user/repo> |
124
|
|
|
|
|
|
|
when it belongs to another GitLab user/organization. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
D Ruth Holloway <ruth@hiruthie.me> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2022 by D Ruth Holloway. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# ABSTRACT: Update a GitLab repo's info on release |
144
|
|
|
|
|
|
|
|