| 1 | package WWW::Gitea::API::PullRequests; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # ABSTRACT: Gitea pull requests API | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 5 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 5 | ▶ | use Carp qw(croak); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 5 | ▶ | use WWW::Gitea::PullRequest; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 5 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | |||||||||||||||
| 11 | 5 | has client => ( | |||||||||||||
| 12 | is => 'ro', | ||||||||||||||
| 13 | required => 1, | ||||||||||||||
| 14 | weak_ref => 1, | ||||||||||||||
| 15 | ); | ||||||||||||||
| 16 | |||||||||||||||
| 17 | |||||||||||||||
| 18 | has openapi_operations => ( | ||||||||||||||
| 19 | is => 'lazy', | ||||||||||||||
| 20 | 0 | ▶ | builder => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Subroutine
_build_openapi_operations: called CC=1 SCAR=1.2
| |||||||||||||||
| 21 | return { | ||||||||||||||
| 22 | 0 | 'pulls.list' => { method => 'GET', path => '/repos/{owner}/{repo}/pulls' }, | |||||||||||||
| 23 | 'pulls.create' => { method => 'POST', path => '/repos/{owner}/{repo}/pulls' }, | ||||||||||||||
| 24 | 'pulls.get' => { method => 'GET', path => '/repos/{owner}/{repo}/pulls/{index}' }, | ||||||||||||||
| 25 | 'pulls.edit' => { method => 'PATCH', path => '/repos/{owner}/{repo}/pulls/{index}' }, | ||||||||||||||
| 26 | 'pulls.merge' => { method => 'POST', path => '/repos/{owner}/{repo}/pulls/{index}/merge' }, | ||||||||||||||
| 27 | 'pulls.is_merged' => { method => 'GET', path => '/repos/{owner}/{repo}/pulls/{index}/merge' }, | ||||||||||||||
| 28 | }; | ||||||||||||||
| 29 | }, | ||||||||||||||
| 30 | 5 | ); | |||||||||||||
| 31 | |||||||||||||||
| 32 | |||||||||||||||
| 33 | 5 | with 'WWW::Gitea::Role::OpenAPI'; | |||||||||||||
| 34 | |||||||||||||||
| 35 | 0 | ▶ | sub _wrap { | ||||||||||||
|
Subroutine
_wrap: not called CC=3 SCAR=24.8
| |||||||||||||||
| 36 | 0 | my ($self, $data, $owner, $repo) = @_; | |||||||||||||
| 37 | 0 | ▶ | return WWW::Gitea::PullRequest->new( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 38 | client => $self->client, | ||||||||||||||
| 39 | data => $data, | ||||||||||||||
| 40 | (defined $owner ? (owner => $owner) : ()), | ||||||||||||||
| 41 | (defined $repo ? (repo => $repo) : ()), | ||||||||||||||
| 42 | ); | ||||||||||||||
| 43 | } | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | ▶ | sub list { | ||||||||||||
|
Subroutine
list: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 46 | 0 | my ($self, $owner, $repo, %query) = @_; | |||||||||||||
| 47 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 49 | 0 | my $data = $self->call_operation('pulls.list', | |||||||||||||
| 50 | path => { owner => $owner, repo => $repo }, query => \%query); | ||||||||||||||
| 51 | 0 | ▶ | return [ map { $self->_wrap($_, $owner, $repo) } @{ $data || [] } ]; | ||||||||||||
|
Condition0%0/2
$data || []
MC/DC0%0/1
$data || []
$data
Truth table0%0/2
A
A= $data
| |||||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | |||||||||||||||
| 55 | 0 | ▶ | sub create { | ||||||||||||
|
Subroutine
create: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||
| 56 | 0 | my ($self, $owner, $repo, %args) = @_; | |||||||||||||
| 57 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 58 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 59 | 0 | ▶ | croak 'head required' unless defined $args{head}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 60 | 0 | ▶ | croak 'base required' unless defined $args{base}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 61 | 0 | ▶ | croak 'title required' unless defined $args{title}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 62 | 0 | my $data = $self->call_operation('pulls.create', | |||||||||||||
| 63 | path => { owner => $owner, repo => $repo }, body => \%args); | ||||||||||||||
| 64 | 0 | return $self->_wrap($data, $owner, $repo); | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | |||||||||||||||
| 67 | |||||||||||||||
| 68 | 0 | ▶ | sub get { | ||||||||||||
|
Subroutine
get: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 69 | 0 | my ($self, $owner, $repo, $index) = @_; | |||||||||||||
| 70 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 71 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 72 | 0 | ▶ | croak 'index required' unless defined $index; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 73 | 0 | my $data = $self->call_operation('pulls.get', | |||||||||||||
| 74 | path => { owner => $owner, repo => $repo, index => $index }); | ||||||||||||||
| 75 | 0 | return $self->_wrap($data, $owner, $repo); | |||||||||||||
| 76 | } | ||||||||||||||
| 77 | |||||||||||||||
| 78 | |||||||||||||||
| 79 | 0 | ▶ | sub edit { | ||||||||||||
|
Subroutine
edit: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 80 | 0 | my ($self, $owner, $repo, $index, %args) = @_; | |||||||||||||
| 81 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 82 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 83 | 0 | ▶ | croak 'index required' unless defined $index; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 84 | 0 | my $data = $self->call_operation('pulls.edit', | |||||||||||||
| 85 | path => { owner => $owner, repo => $repo, index => $index }, | ||||||||||||||
| 86 | body => \%args); | ||||||||||||||
| 87 | 0 | return $self->_wrap($data, $owner, $repo); | |||||||||||||
| 88 | } | ||||||||||||||
| 89 | |||||||||||||||
| 90 | |||||||||||||||
| 91 | 0 | ▶ | sub merge { | ||||||||||||
|
Subroutine
merge: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||
| 92 | 0 | my ($self, $owner, $repo, $index, %args) = @_; | |||||||||||||
| 93 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 94 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 95 | 0 | ▶ | croak 'index required' unless defined $index; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 96 | 0 | ▶ | $args{Do} //= 'merge'; | ||||||||||||
|
Condition0%0/2
$args{"Do"} //= "merge"
MC/DC0%0/1
$args{"Do"} //= "merge"
$args{"Do"}
Truth table0%0/2
A
A= $args{"Do"}
| |||||||||||||||
| 97 | 0 | return $self->call_operation('pulls.merge', | |||||||||||||
| 98 | path => { owner => $owner, repo => $repo, index => $index }, | ||||||||||||||
| 99 | body => \%args); | ||||||||||||||
| 100 | } | ||||||||||||||
| 101 | |||||||||||||||
| 102 | |||||||||||||||
| 103 | 0 | ▶ | sub is_merged { | ||||||||||||
|
Subroutine
is_merged: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||
| 104 | 0 | my ($self, $owner, $repo, $index) = @_; | |||||||||||||
| 105 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 106 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 107 | 0 | ▶ | croak 'index required' unless defined $index; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 108 | 0 | my $op = $self->get_operation('pulls.is_merged'); | |||||||||||||
| 109 | my $path = $self->_resolve_path($op->{path}, | ||||||||||||||
| 110 | 0 | { owner => $owner, repo => $repo, index => $index }); | |||||||||||||
| 111 | 0 | my $code = $self->client->request_status($op->{method}, $path); | |||||||||||||
| 112 | 0 | ▶ | return $code == 204 ? 1 : 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 113 | } | ||||||||||||||
| 114 | |||||||||||||||
| 115 | |||||||||||||||
| 116 | |||||||||||||||
| 117 | 5 | 1; | |||||||||||||
| 118 | |||||||||||||||
| 119 | __END__ | ||||||||||||||