| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Gitea::API::Repos; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Gitea repositories API |
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
17
|
use Moo; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
15
|
|
|
6
|
3
|
|
|
3
|
|
823
|
use Carp qw(croak); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
166
|
|
|
7
|
3
|
|
|
3
|
|
1274
|
use WWW::Gitea::Repo; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
119
|
|
|
8
|
3
|
|
|
3
|
|
18
|
use namespace::clean; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has client => ( |
|
12
|
|
|
|
|
|
|
is => 'ro', |
|
13
|
|
|
|
|
|
|
required => 1, |
|
14
|
|
|
|
|
|
|
weak_ref => 1, |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has openapi_operations => ( |
|
19
|
|
|
|
|
|
|
is => 'lazy', |
|
20
|
|
|
|
|
|
|
builder => sub { |
|
21
|
|
|
|
|
|
|
return { |
|
22
|
1
|
|
|
1
|
|
30
|
'repos.get' => { method => 'GET', path => '/repos/{owner}/{repo}' }, |
|
23
|
|
|
|
|
|
|
'repos.edit' => { method => 'PATCH', path => '/repos/{owner}/{repo}' }, |
|
24
|
|
|
|
|
|
|
'repos.delete' => { method => 'DELETE', path => '/repos/{owner}/{repo}' }, |
|
25
|
|
|
|
|
|
|
'repos.search' => { method => 'GET', path => '/repos/search' }, |
|
26
|
|
|
|
|
|
|
'repos.fork' => { method => 'POST', path => '/repos/{owner}/{repo}/forks' }, |
|
27
|
|
|
|
|
|
|
'repos.create_current' => { method => 'POST', path => '/user/repos' }, |
|
28
|
|
|
|
|
|
|
'repos.create_org' => { method => 'POST', path => '/orgs/{org}/repos' }, |
|
29
|
|
|
|
|
|
|
'repos.list_current' => { method => 'GET', path => '/user/repos' }, |
|
30
|
|
|
|
|
|
|
'repos.list_user' => { method => 'GET', path => '/users/{username}/repos' }, |
|
31
|
|
|
|
|
|
|
}; |
|
32
|
|
|
|
|
|
|
}, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
with 'WWW::Gitea::Role::OpenAPI'; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _wrap { |
|
39
|
0
|
|
|
0
|
|
|
my ($self, $data) = @_; |
|
40
|
0
|
|
|
|
|
|
return WWW::Gitea::Repo->new(client => $self->client, data => $data); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub get { |
|
44
|
0
|
|
|
0
|
1
|
|
my ($self, $owner, $repo) = @_; |
|
45
|
0
|
0
|
|
|
|
|
croak 'owner required' unless defined $owner; |
|
46
|
0
|
0
|
|
|
|
|
croak 'repo required' unless defined $repo; |
|
47
|
0
|
|
|
|
|
|
my $data = $self->call_operation('repos.get', |
|
48
|
|
|
|
|
|
|
path => { owner => $owner, repo => $repo }); |
|
49
|
0
|
|
|
|
|
|
return $self->_wrap($data); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub create { |
|
54
|
0
|
|
|
0
|
1
|
|
my ($self, %args) = @_; |
|
55
|
0
|
0
|
|
|
|
|
croak 'name required' unless defined $args{name}; |
|
56
|
0
|
|
|
|
|
|
my $org = delete $args{org}; |
|
57
|
0
|
|
|
|
|
|
my $body = { %args }; |
|
58
|
0
|
|
|
|
|
|
my $data; |
|
59
|
0
|
0
|
|
|
|
|
if (defined $org) { |
|
60
|
0
|
|
|
|
|
|
$data = $self->call_operation('repos.create_org', |
|
61
|
|
|
|
|
|
|
path => { org => $org }, body => $body); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
else { |
|
64
|
0
|
|
|
|
|
|
$data = $self->call_operation('repos.create_current', body => $body); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
0
|
|
|
|
|
|
return $self->_wrap($data); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub edit { |
|
71
|
0
|
|
|
0
|
1
|
|
my ($self, $owner, $repo, %args) = @_; |
|
72
|
0
|
0
|
|
|
|
|
croak 'owner required' unless defined $owner; |
|
73
|
0
|
0
|
|
|
|
|
croak 'repo required' unless defined $repo; |
|
74
|
0
|
|
|
|
|
|
my $data = $self->call_operation('repos.edit', |
|
75
|
|
|
|
|
|
|
path => { owner => $owner, repo => $repo }, body => \%args); |
|
76
|
0
|
|
|
|
|
|
return $self->_wrap($data); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub delete { |
|
81
|
0
|
|
|
0
|
1
|
|
my ($self, $owner, $repo) = @_; |
|
82
|
0
|
0
|
|
|
|
|
croak 'owner required' unless defined $owner; |
|
83
|
0
|
0
|
|
|
|
|
croak 'repo required' unless defined $repo; |
|
84
|
0
|
|
|
|
|
|
return $self->call_operation('repos.delete', |
|
85
|
|
|
|
|
|
|
path => { owner => $owner, repo => $repo }); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub search { |
|
90
|
0
|
|
|
0
|
1
|
|
my ($self, %query) = @_; |
|
91
|
0
|
|
|
|
|
|
my $data = $self->call_operation('repos.search', query => \%query); |
|
92
|
0
|
0
|
|
|
|
|
return [ map { $self->_wrap($_) } @{ $data->{data} || [] } ]; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub fork { |
|
97
|
0
|
|
|
0
|
1
|
|
my ($self, $owner, $repo, %args) = @_; |
|
98
|
0
|
0
|
|
|
|
|
croak 'owner required' unless defined $owner; |
|
99
|
0
|
0
|
|
|
|
|
croak 'repo required' unless defined $repo; |
|
100
|
0
|
|
|
|
|
|
my $data = $self->call_operation('repos.fork', |
|
101
|
|
|
|
|
|
|
path => { owner => $owner, repo => $repo }, body => \%args); |
|
102
|
0
|
|
|
|
|
|
return $self->_wrap($data); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub list { |
|
107
|
0
|
|
|
0
|
1
|
|
my ($self, %args) = @_; |
|
108
|
0
|
|
|
|
|
|
my $username = delete $args{username}; |
|
109
|
0
|
|
|
|
|
|
my $data; |
|
110
|
0
|
0
|
|
|
|
|
if (defined $username) { |
|
111
|
0
|
|
|
|
|
|
$data = $self->call_operation('repos.list_user', |
|
112
|
|
|
|
|
|
|
path => { username => $username }, query => \%args); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
else { |
|
115
|
0
|
|
|
|
|
|
$data = $self->call_operation('repos.list_current', query => \%args); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
0
|
0
|
|
|
|
|
return [ map { $self->_wrap($_) } @{ $data || [] } ]; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |